PasswordInput
A password. Its value is never rendered back to the browser.
use Anvil\Schema\Fields\PasswordInput;
PasswordInput::make('password')->required()->hiddenOn(FormContext::EDIT, FormContext::VIEW),PasswordInput::make('current_password')->autocomplete('current-password'),Options
Section titled “Options”| Option | Effect | Default |
|---|---|---|
autocomplete('…') |
autocomplete attribute; current-password for a login, new-password lets password managers suggest one |
new-password |
Plus the options of every field.
Behaviour
Section titled “Behaviour”- The input is always empty when the form is opened, also when editing.
- The value is taken as entered, including spaces at the start and end.
- An empty optional field is
null: when editing, leaving it empty usually means “keep the current password” – handle that in the model or inafterSave(). - Hashing is not done by the field. Hash in the model (e.g. a
beforeInsertcallback) or inafterSave(); Shield users are handled by the user administration.
Validation
Section titled “Validation”string, max_byte[72] (the bcrypt limit), then the rules of rules(),
e.g. a minimum length or matches[password] for a confirmation field.
Read-only
Section titled “Read-only”••••••••.
Write-only (writeOnly: true), never part of the representation.