On this page
@addTagHelper *, Webority.Ui.RazorRename a project
A short form, such as a rename or a note, opens in a dialog and posts back to the same page.
Rename and show an error
Destructive action
Use the danger tone on the submit button of an action that removes something, such as an archive. Add focus-cancel so the dialog opens on Cancel.
Archive a project
The archive dialog draws its submit button in the danger tone.
Fields, selects and rows
A longer form mixes single fields with two-column rows. Every field and row sits the same distance from the next.
Fields, selects and rows
Stacked fields, a select with helper text and two-column rows keep one distance between them.
Upload a file
A dialog that attaches a file posts it as multipart form data.
Upload a file
Set enctype to MultipartFormData and the form posts the file with the other fields.
Page hooks and a disabled submit
A page script finds its own hook on the form and enables the submit button once the person may post.
Page hook and a disabled submit
A data attribute on the tag lands on the form, so a page script finds it. The submit button starts disabled and the script enables it.
Every option
Every value of every prop, one cell each.
id
id (required): names the form that the footer buttons submit, no visible change
action
action not set (default): the form posts back to the current page, no visible change
method
method="post" (default): the form carries the antiforgery field
method="get": no antiforgery field, the fields post in the query string
enctype
enctype not set (default): the form posts urlencoded, no visible change
enctype="AppModalFormEnctype.MultipartFormData": the form posts its files
submit-label
submit-label not set (default): the submit button reads Save
submit-label="Rename": the submit button reads Rename
cancel-label
cancel-label not set (default): the cancel button reads Cancel
cancel-label="Keep editing": the cancel button reads Keep editing and still closes the dialog without posting
danger
danger="false" (default): the submit button uses the primary tone
danger="true": the submit button uses the danger tone, for a destructive action
focus-cancel
focus-cancel="false" (default): focus lands on the first field
focus-cancel="true": focus lands on the Cancel button
submit-disabled
submit-disabled="false" (default): the submit button is enabled
submit-disabled="true": the submit button is drawn disabled
hide-submit
hide-submit="false" (default): the footer holds Cancel and the submit button
hide-submit="true": the footer holds only Cancel
Reference
Try every prop, read the full list, and check keyboard and screen reader behaviour.
11 props.
Less common 11 props
| Prop | Type | Default | Description |
|---|---|---|---|
| iddefault - | string | - | The form's element id, which the footer buttons name. Required; a missing id throws. |
| actiondefault - | string | - | Where the form posts. Unset posts back to the current page. |
| methoddefault post | post | get | post | A get form carries no antiforgery field. Any other value throws. |
| enctypedefault - | MultipartFormData | ApplicationXWwwFormUrlencoded | - | Writes the form's enctype. Set MultipartFormData for a form with a file input. Unset writes none. Needs the post method; a get form with an enctype throws. |
| submit-labeldefault Save | string | Save | The submit button's label. |
| cancel-labeldefault Cancel | string | Cancel | The cancel button's label. It closes the dialog without posting. |
| dangerdefault false | bool | false | Draws the submit button in the danger tone, for a destructive action. |
| focus-canceldefault false | bool | false | Puts initial focus on the Cancel button when the dialog opens, for a destructive action. Unset, focus lands on the first field. |
| submit-disableddefault false | bool | false | Draws the submit button disabled, for a form the page script enables later. Not with hide-submit; both throw. |
| hide-submitdefault false | bool | false | Leaves the submit button out of the footer, for a dialog the page script submits or that only shows. Not with submit-disabled; both throw. |
| data-*default - | string | - | Any other attribute, such as a data hook, is written onto the form element. |