Form
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 = falsePosts 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 = trueUses Blazor's enhanced form handling on static pages (no full page reload). Defaults to true.
NativeValidationbool = trueLets 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.VerticalHow labels sit next to fields. Defaults to stacked.
Space between fields, in spacing steps. Defaults to 5.
Columnsint = 1Lays 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 = falseDisables every field in the form. Disabled fields can't be changed or focused and aren't posted. Buttons are left as they are.
ReadOnlybool = falseMakes 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.RequiredWhich 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)
Margin on all sides, in spacing steps (-16 to 16; one step = 4px).
Width.
Minimum width.
Maximum width.
Growbool = falseWhether to grow into free space inside a Stack, Row or Column: <Box Grow>.
Shrinkbool = trueWhether to shrink when space is short inside a Stack, Row or Column. Defaults to true; Shrink="false" keeps the size.
Starting size inside a Stack, before growing or shrinking.
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.
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.
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.
Where the buttons go along the row. Defaults to the end.
Plus 16 item props and 4 common props.
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
enumHow a Form lays out labels and fields.
| Value | Description |
|---|---|
Vertical | Labels above fields (the default). |
Horizontal | Labels in a column to the left of fields, from 640px up. |
Justify
enumMain-axis distribution of a Stack's children.
| Value | Description |
|---|---|
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
enumWhich fields a Form marks beside their labels.
| Value | Description |
|---|---|
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. |