Skip to content
IzzyBlazor 0.1.0-alpha.17

Enter all results ↑ ↓ move Esc close

Form

Posts on static pages, validates live on interactive ones.

IzzyBlazor.Form in the IzzyBlazor.Core package, generated from the 0.1.0-alpha.17 assembly and its doc comments.

Properties (14)

Modelobject?

The object the form edits. Set this or EditContext.

EditContextEditContext?

An explicit edit context. Set this or Model.

FormNamestring?

The form's name. Required on static pages, where it tells Blazor which form a POST belongs to; pair it with [SupplyParameterFromForm(FormName = "...")] on the model property.

Multipartbool = false

Posts as multipart/form-data, which a FileUpload needs to send its files on static pages. Without it, a post sends only the file names.

Enhancebool = true

Uses Blazor's enhanced form handling on static pages (no full page reload). Defaults to true.

NativeValidationbool = true

Lets the browser check required fields, lengths and formats before posting. Defaults to true.

ValidatorRenderFragment?

Replaces the default DataAnnotations validator, for example with a FluentValidation one.

LayoutFormLayout = FormLayout.Vertical

How labels sit next to fields. Defaults to stacked.

GapResponsive<int> = 5Responsive

Space between fields, in spacing steps. Defaults to 5.

Columnsint = 1

Lays the fields out in up to this many columns (1 to 4). Defaults to 1. The form shows fewer when it's narrow, by its own width rather than the screen's, so the same form fits a page, a dialog and a drawer: two columns from 32rem, three from 48rem, four from 64rem. Fields take one column and anything else (text, errors, buttons, a Fieldset) the whole row; set ColSpan to change either.

Disabledbool = false

Disables every field in the form. Disabled fields can't be changed or focused and aren't posted. Buttons are left as they are.

ReadOnlybool = false

Makes every field read-only: shown and posted, but not changed, as on a page that shows a record before editing it. HTML has no read-only select, checkbox, radio or range, so a read-only Select, Combobox or MultiSelect shows its value in a read-only text field, and checkboxes, switches, radios, segments and sliders are disabled; their values post from hidden inputs.

RequiredMarkRequiredMark = RequiredMark.Required

Which fields are marked beside their labels: RequiredMark.Required (an asterisk on required fields, the default), RequiredMark.Optional ("(optional)" on the others) or RequiredMark.None. Whether a field is required still comes from [Required] or its own Required.

ChildContentRenderFragment?

The fields and buttons.

Item props (from LayoutItemBase)

MarginResponsive<int>Responsive

Margin on all sides, in spacing steps (-16 to 16; one step = 4px).

MarginXResponsive<int>Responsive

Horizontal margin. When set, replaces Margin on this axis.

MarginYResponsive<int>Responsive

Vertical margin. When set, replaces Margin on this axis.

MarginTopResponsive<int>Responsive

Top margin. When set, replaces MarginY and Margin on this side.

MarginBottomResponsive<int>Responsive

Bottom margin. When set, replaces MarginY and Margin on this side.

MarginStartResponsive<int>Responsive

Margin at the start (left in left-to-right text, right in right-to-left). Replaces MarginX and Margin on this side.

MarginEndResponsive<int>Responsive

Margin at the end (right in left-to-right text, left in right-to-left). Replaces MarginX and Margin on this side.

WidthResponsive<Length>Responsive

Width.

MinWidthResponsive<Length>Responsive

Minimum width.

MaxWidthResponsive<Length>Responsive

Maximum width.

Growbool = false

Whether to grow into free space inside a Stack, Row or Column: <Box Grow>.

Shrinkbool = true

Whether to shrink when space is short inside a Stack, Row or Column. Defaults to true; Shrink="false" keeps the size.

BasisResponsive<Length>Responsive

Starting size inside a Stack, before growing or shrinking.

AlignSelfResponsive<Align>Responsive

Alignment across the parent's direction, overriding the parent's Align for this component only, such as a button lined up with the bottom of labeled fields in a Row.

ColSpanResponsive<int>Responsive

How many columns it spans in a Form or Fieldset with Columns, or a Grid; GridSpan.Full for the whole row. Never more than the columns shown, so a form that narrows to one column needs no breakpoints.

NewRowbool = false

Starts a new row in a Form or Fieldset with Columns, or a Grid, leaving the rest of the row before it empty.

Common props (from IzzyComponentBase)

Classstring?

Extra CSS classes, merged after the component's own classes.

Stylestring?

Inline style, appended after the component's generated custom properties.

HiddenFromBreakpoint?

Hides the component from this breakpoint up, such as a menu button only phones need.

VisibleFromBreakpoint?

Shows the component only from this breakpoint up, such as header links for wide screens.

Events (3)

OnValidSubmitEventCallback<EditContext>

Runs on the server after a submit that passes validation.

OnInvalidSubmitEventCallback<EditContext>

Runs on the server after a submit that fails validation.

OnSubmitEventCallback<EditContext>

Runs on every submit, instead of the valid and invalid callbacks. You validate yourself.

Parts (2)

Components written inside Form, documented here with it.

FormActions

The row of buttons at the end of a form. It takes the whole row in a form with Columns and puts the buttons at the end. Last in a form that fills a Dialog or Drawer, it becomes the dialog's footer, like DialogFooter: it reaches the edges and stays in view when the body scrolls.

ChildContentRenderFragment?

The buttons, in reading order: usually Cancel, then the main action.

JustifyResponsive<Justify> (computed)Responsive

Where the buttons go along the row. Defaults to the end.

FormErrors

A summary of every validation message in the form. Place it at the top of a long form. After a submit that fails validation it takes focus, so keyboard and screen reader users start from the list of problems, and screen readers read it then: a group named by its title and described by the messages. It isn't a live region as well, which would read it twice (once as it appears, once on focus):

  • static pages: native autofocus on a full page load (works with JavaScript off), and the script for an enhanced post, which patches the page so autofocus doesn't fire;
  • interactive pages: focused from C# after the submit, but not as messages change while typing.
Titlestring? = "Please fix the following"

The heading. Defaults to "Please fix the following".

Types (3)

FormLayout

enum

How a Form lays out labels and fields.

FormLayout values
ValueDescription
Vertical

Labels above fields (the default).

Horizontal

Labels in a column to the left of fields, from 640px up.

Justify

enum

Main-axis distribution of a Stack's children.

Justify values
ValueDescription
Start

Packed at the start.

Center

Packed in the center.

End

Packed at the end.

Between

First and last at the edges, equal space between.

Around

Equal space around each child.

Evenly

Equal space between and at the edges.

RequiredMark

enum

Which fields a Form marks beside their labels.

RequiredMark values
ValueDescription
Required

Required fields get an asterisk (the default).

Optional

Fields that aren't required get "(optional)"; required ones get nothing. Suits forms where most fields are required.

None

No marks.