Skip to content

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'),
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.

  • 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 in afterSave().
  • Hashing is not done by the field. Hash in the model (e.g. a beforeInsert callback) or in afterSave(); Shield users are handled by the user administration.

string, max_byte[72] (the bcrypt limit), then the rules of rules(), e.g. a minimum length or matches[password] for a confirmation field.

••••••••.

Write-only (writeOnly: true), never part of the representation.