Skip to content
daisyBlazor

Form

Form stacks fields with even spacing and validates the TextField, NumericField and Select inside it: Validate() runs each field's Required and Validation checks and updates IsValid, as MudForm does. Validator and ValidatorHint add daisyUI's CSS-only validation; ServerValidation and FieldError show errors returned by an API.
Data input.validatorReplaces MudForm
Cover · <Form>

Join the beta

That address looks unfinished.

Examples

Layout

A bound order form; the record below echoes every field as you edit.

Order { Name = Ana Silva, Email = , Plan = Pro, Newsletter = False }

website/Examples/DataInput/FormBasicExample.razor Source

Field validation

Validate() checks Required and each field's Validation func and binds IsValid; fields re-check as you edit them.

Lowercase letters, digits and dashes.
IsValid: True
website/Examples/DataInput/FormFieldValidationExample.razor Source

CSS validation

Validator turns the browser's :invalid state into daisyUI colours and reveals its hint after the user touches the field.

Enter a valid email address.

Use the form “INV-2041”.

email= · invoice=inv-2041

website/Examples/DataInput/FormValidatorExample.razor Source

Server errors

ServerValidation cascades an error set; fields with a FieldName and any FieldError pick their message up.

Your rating
website/Examples/DataInput/FormServerValidationExample.razor Source

API

<Form>

DaisyBlazor

Parameters

  • IsValid bool
    = true

    True when every registered field passed its last check. Updated by Validate() and by field edits; bind with @bind-IsValid.

  • Model object
    = null

    The object passed to a form-level Validation of shape Func<object, string, IEnumerable<string>> (model, FieldName).

  • Validation object
    = null

    Validation applied to every field that has no Validation of its own. Same shapes as a field's Validation, plus Func<object, string, IEnumerable<string>> called with (Model, FieldName).

  • Class string
    = null

    Extra CSS classes merged onto the root element.

  • Style string
    = null

    Inline CSS styles applied to the root element.

Events

  • IsValidChanged EventCallback<bool>

    Raised when IsValid changes.

Content

  • ChildContent RenderFragment

    Form fields rendered inside a vertical flex container with gap-3.

<Validator>

DaisyBlazor

Parameters

  • Hint string
    = null

    Optional hint rendered after the inputs as a .validator-hint paragraph, shown once an input is invalid.

  • Class string
    = null

    Extra CSS classes applied to the outer wrapper (around the inputs and the hint).

  • Style string
    = null

    Inline CSS styles applied to the outer wrapper.

Content

  • ChildContent RenderFragment

    The input element(s) to validate, wrapped in a .validator element.

<ValidatorHint>

DaisyBlazor

Parameters

  • Class string
    = null

    Extra CSS classes merged onto the .validator-hint paragraph.

  • Style string
    = null

    Inline CSS styles applied to the paragraph.

Content

  • ChildContent RenderFragment

    The hint message content to display beneath a validated input.

<ServerValidation>

DaisyBlazor.Validation

Parameters

  • State ServerValidationState
    = required

    The error set to cascade. Usually a field on the page, reused across submits.

Content

  • ChildContent RenderFragment

    The form (or any markup) whose inputs should react to State.

<FieldError>

DaisyBlazor.Validation

Parameters

  • For string
    = required

    Field name to report errors for. Matched case-insensitively, and against the last dot-separated segment, so request.Name matches Name.

  • Class string
    = null

    Extra CSS classes appended to each message.

  • Style string
    = null

    Optional inline style applied to each message.

From MudForm

Form keeps MudForm's parameter names, so most markup moves over by dropping the Mud prefix. See the migration guide for the shared enums, icons and services.

Validate(), IsValid/IsValidChanged, Required/RequiredError and field Validation funcs (Func<T, string?>, Func<T, bool>, Func<T, IEnumerable<string>>) work as in MudForm on TextField, NumericField and Select. Validation is synchronous, For expressions are ignored, and a form-level Validation of shape Func<object, string, IEnumerable<string>> receives Model and the field's FieldName. ResetAsync() clears errors but not values.

<MudForm> <Form>
Something went wrong while running the docs. Reload