Ignite rocketboost.rs

Forms

The new and edit pages draw a form from the resource's fields. When the form is submitted, the resource's validate method, or validate_update on an edit, turns the values into its input, or returns a message for each field.

Field kinds

Each field has a kind, which sets the input and how the value is read:

  • Text, a single-line text input.
  • Textarea, a multi-line text input.
  • Password, a password input. The form never fills it in, not even on edit.
  • Number, a number input. The value is read as text, and the resource parses it.
  • Checkbox, a tick box. A tick sends on, and an empty box sends nothing, so the value is false.
  • Select, a list of (value, label) choices.
  • Date, a date input. The value is read as YYYY-MM-DD.

A hand-written resource can use every kind. The derive can use all of them except Select. A derived password field is a String, and it is hashed on save. See Resources.

The panel does not check a Select value against its choices. The resource's validate must do that.

Required fields

A field marked required shows an asterisk after its label. The asterisk is only a hint: the resource's validate must reject a blank value. The derive does this for you, and a hand-written resource calls check_required, which trims the value and records the message <label> is required. if it is blank.

Validation errors

When validate returns errors, the panel shows the form again with the values the user typed, a message under each field that has one, and the status 422. Nothing is written to the database. A derived field that cannot be read, such as a number that is not a whole number, gets its own message, such as Price must be a whole number.

A value that clashes with a unique index is also a field error. A second user with the same email, for example, shows Email is already taken. under the email field, with the status 422. Any other database error is a 500.

Passwords

A password field is never filled in on the edit page. On create, a password is required. On edit, a blank password keeps the stored hash, and a new one is hashed with argon2 on save. A hand-written resource hashes with ignite_core::hash_password itself, and overrides validate_update to allow a blank password on edit. See Resources.

Forms and tokens

Every panel form carries a hidden _token field, which the panel checks on submit. An app's own forms do the same, with CsrfForm. See Panel. A form that was open too long shows the Page Expired page, with status 419, and nothing is saved. See Panel.

Not built yet

  • Help text and file fields. A field has a label and a kind. There is no help text, and no upload.