日本語

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>.

ItemSummary
Form::newA form that starts from value, untouched and not yet submitted.
Form::validateChecks 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.

ItemSummary
valueThe values of the form.
fieldThe field field of the form's values, for binding a control to it.
errorThe message to show under field, or "".
formA <form> that, on submit, touches every field with a rule and runs then if every rule passes.
touchA statement that marks field as left by the visitor.
resetA statement that puts back the starting values and forgets what the visitor has done.
is_dirtyWhether the form's values differ from the values it started from.
is_field_dirtyWhether field differs from the value it started from.
is_touchedWhether the visitor has left field, or has submitted the form while field has a rule.
is_submittedWhether the visitor has submitted the form since it started or was reset.
is_validWhether every rule of T passes for the form's values.
rejectA 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.

ItemSummary
Validate::rulesAdds a check to rules for each field of form that can be wrong.
Rules::checkReports message for field while ok is false.
FieldErrors::newNo messages.
FieldErrors::addThese messages, with message for field in place of any it had.
FieldErrors::messageThe message for field, if it has one.