Form and Validate
Form<T> holds a form's values, the values it started from, and what the visitor has done to it. Validate gives the rules that the browser and the server both evaluate.
Form
Put one in the page's signal struct as a field of type Form<T>.
| Item | Summary |
|---|---|
Form::new | A form that starts from value, untouched and not yet submitted. |
Form::validate | Checks value against the rules of T on the server. |
Sig<S, Form<T>>
The methods on the form's signal read and change it on the page.
| Item | Summary |
|---|---|
value | The values of the form. |
field | The field field of the form's values, for binding a control to it. |
error | The message to show under field, or "". |
form | A <form> that, on submit, touches every field with a rule and runs then if every rule passes. |
touch | A statement that marks field as left by the visitor. |
reset | A statement that puts back the starting values and forgets what the visitor has done. |
is_dirty | Whether the form's values differ from the values it started from. |
is_field_dirty | Whether field differs from the value it started from. |
is_touched | Whether the visitor has left field, or has submitted the form while field has a rule. |
is_submitted | Whether the visitor has submitted the form since it started or was reset. |
is_valid | Whether every rule of T passes for the form's values. |
reject | A patch that shows errors under their fields until the next submit. |
Validate and Rules
rules is generic over the page, so the same expressions are built for the browser and for Form::validate.
| Item | Summary |
|---|---|
Validate::rules | Adds a check to rules for each field of form that can be wrong. |
Rules::check | Reports message for field while ok is false. |
FieldErrors::new | No messages. |
FieldErrors::add | These messages, with message for field in place of any it had. |
FieldErrors::message | The message for field, if it has one. |