Login - Simple Form

Demonstrates basic form fields and validation Async

Your username or email address
Your account password
Keep me logged in on this device
Rendered in 0.000s
Debug panel (development only) — 0.000s render
<style data-schemaforms-layout-support>
.pydantic-form,
.md-form {
    width: 100%;
    max-width: none;
}

.pydantic-form > div,
.pydantic-form > fieldset,
.pydantic-form > [class*="row"],
.md-form > div,
.md-form > fieldset,
.md-form > [class*="row"] {
    width: 100% !important;
    max-width: none !important;
}

.pydantic-form [class*="col-"],
.md-form [class*="col-"] {
    min-width: 0;
    flex: 1 1 auto !important;
}

.pydantic-form [class*="section"],
.pydantic-form [data-schemaforms-section],
.pydantic-form fieldset,
.md-form [class*="section"],
.md-form [data-schemaforms-section],
.md-form fieldset {
    width: 100% !important;
    max-width: none !important;
    box-sizing: border-box;
}
</style>


<form id=""
      class="pydantic-form "
      style=""
      method="POST"
      action="/login?style=none"
      novalidate>
    
    <div class="field"><label for="username">Username *</label>
<input name="username" id="username" value="demo_user" required="required" minlength="3" maxlength="50" placeholder="Enter your username" type="text" />
<div class="help-text">Your username or email address</div></div>
<div class="field"><label for="password">Password *</label>
<input name="password" id="password" value="demo_pass" required="required" minlength="6" placeholder="Enter your password" autocomplete="new-password" type="password" />
<div class="help-text">Your account password</div></div>
<div class="field"><label for="remember_me">Remember me</label>
<input name="remember_me" id="remember_me" checked="checked" value="1" type="checkbox" />
<div class="help-text">Keep me logged in on this device</div></div>
    
<button type="submit">Submit</button>
<div style="margin-top: 0.5rem; font-size: 0.75rem; color: #6c757d; text-align: right;">Rendered in 0.000s</div>
</form>


<script>
(function() {
    document.addEventListener('DOMContentLoaded', function() {
        // Prevent Enter key from submitting forms unless on submit button
        const forms = document.querySelectorAll('form.pydantic-form');
        forms.forEach(function(form) {
            form.addEventListener('keydown', function(e) {
                // Check if Enter key is pressed
                if (e.key === 'Enter' || e.keyCode === 13) {
                    const target = e.target;

                    // Allow Enter in textareas (for multi-line input)
                    if (target.tagName === 'TEXTAREA') {
                        return;
                    }

                    // Allow Enter on submit buttons
                    if (target.tagName === 'BUTTON' && target.type === 'submit') {
                        return;
                    }

                    // Allow Enter on input type="submit"
                    if (target.tagName === 'INPUT' && target.type === 'submit') {
                        return;
                    }

                    // Prevent form submission for all other cases
                    e.preventDefault();
                    return false;
                }
            });
        });
    });
})();
</script>
class MinimalLoginForm(FormModel):
    """Minimal form example - Simple login form."""

    username: str = FormField(
        title="Username",
        input_type="text",
        placeholder="Enter your username",
        help_text="Your username or email address",
        icon="person",
        min_length=3,
        max_length=50,
    )

    password: str = FormField(
        title="Password",
        input_type="password",
        placeholder="Enter your password",
        help_text="Your account password",
        icon="lock",
        min_length=6,
    )

    remember_me: bool = FormField(
        False,
        title="Remember me",
        input_type="checkbox",
        help_text="Keep me logged in on this device",
        icon="check2-square",
    )

    @field_validator("username")
    @classmethod
    def validate_username(cls, v):
        if not v.strip():
            raise ValueError("Username cannot be empty")
        return v.strip()
{
  "description": "Minimal form example - Simple login form.",
  "properties": {
    "username": {
      "autofocus": false,
      "description": "Your username or email address",
      "disabled": false,
      "help_text": "Your username or email address",
      "icon": "person",
      "input_type": "text",
      "maxLength": 50,
      "minLength": 3,
      "placeholder": "Enter your username",
      "readonly": false,
      "title": "Username",
      "type": "string"
    },
    "password": {
      "autofocus": false,
      "description": "Your account password",
      "disabled": false,
      "help_text": "Your account password",
      "icon": "lock",
      "input_type": "password",
      "minLength": 6,
      "placeholder": "Enter your password",
      "readonly": false,
      "title": "Password",
      "type": "string"
    },
    "remember_me": {
      "autofocus": false,
      "default": false,
      "description": "Keep me logged in on this device",
      "disabled": false,
      "help_text": "Keep me logged in on this device",
      "icon": "check2-square",
      "input_type": "checkbox",
      "readonly": false,
      "title": "Remember me",
      "type": "boolean"
    }
  },
  "required": [
    "username",
    "password"
  ],
  "title": "MinimalLoginForm",
  "type": "object"
}
{
  "username": {
    "required": true,
    "type": "string",
    "minLength": 3,
    "maxLength": 50
  },
  "password": {
    "required": true,
    "type": "string",
    "minLength": 6
  },
  "remember_me": {
    "required": false,
    "type": "boolean"
  }
}
{
  "errors": {},
  "data": {
    "username": "demo_user",
    "password": "demo_pass",
    "remember_me": true
  }
}
API Endpoints Available
Schema: GET /api/forms/login/schema
Render: GET /api/forms/login/render
Submit: POST /api/forms/login/submit