InputfieldPassword
InputfieldPassword renders password inputs with confirmation, optional
old-password verification, live strength feedback, and server-side password
validation
It extends InputfieldText, so it inherits standard text-input and
Inputfield behavior, but hides or overrides several text settings because
password handling is more specialized.
$f = $modules->get('InputfieldPassword');
$f->name = 'pass';
$f->label = 'Set Password';
$f->attr('minlength', 8);
$f->requirements = [
InputfieldPassword::requireUpperLetter,
InputfieldPassword::requireLowerLetter,
InputfieldPassword::requireDigit,
InputfieldPassword::requireOther,
];
$form->add($f); For shared Inputfield behavior such as attributes, labels, collapsed states,
showIf, rendering, and processing, see the main Inputfield API documentation.
Expand all Collapse all API reference
| Property | Type | Default | Description |
|---|---|---|---|
requirements | array | [ 'letter', 'digit' ] | Active character-class requirements. |
requirementsLabels | array | labels | Human-readable labels for requirements. |
complexifyBanMode | string | 'loose' | Client-side common-password ban mode: 'loose' or 'strict'. |
complexifyFactor | float|string | 0.7 | Client-side strength factor. Lower numbers allow weaker passwords. |
requireOld | int | 0 | Whether the current password is required before changes. |
showPass | bool | false | Whether existing password values may be rendered/repopulated. |
unmask | bool | false | Whether to render a show/hide password toggle. |
defaultLabel | string | 'Set Password' | Default label assigned during init(). |
oldPassLabel | string | 'Current password' | Label/placeholder for the old-password input. |
newPassLabel | string | 'New password' | Label/placeholder for the new-password input. |
confirmLabel | string | 'Confirm' | Label/placeholder for the confirm-password input. |
Constructor defaults include type='password', size=30, maxlength=256, and
minlength=6.
Password character-class requirements:
| Constant | Value | Meaning |
|---|---|---|
requireLetter | 'letter' | At least one Unicode letter. |
requireLowerLetter | 'lower' | At least one lowercase Unicode letter. |
requireUpperLetter | 'upper' | At least one uppercase Unicode letter. |
requireDigit | 'digit' | At least one Unicode digit. |
requireOther | 'other' | At least one punctuation or symbol character. |
requireNone | 'none' | Disable character-class requirements. Minimum length and invalid whitespace are still checked. |
Old-password requirement constants:
| Constant | Value | Meaning |
|---|---|---|
requireOldAuto | 0 | Auto/default. processInput() does not enforce old password by itself. |
requireOldYes | 1 | Require old password when a logged-in user changes the value. |
requireOldNo | -1 | Do not require old password. |
render() outputs the new-password input, confirmation input, live strength
feedback markup, and optionally an old-password input or show/hide toggle.
$f = $modules->get('InputfieldPassword');
$f->name = 'pass';
$f->unmask = true;
echo $f->render(); When showPass is false, the new-password input value is cleared during render
so existing passwords are not exposed in markup. The value is restored to the
Inputfield object after rendering.
When requireOld > 0 and the current user is logged in, render() also outputs
an old-password input named "_old_$name".
renderValue() returns masked output by default:
$f->value = 'secret';
echo $f->renderValue(); // <p>******</p>If showPass is true, the actual value is entity-encoded and rendered instead.
Processes submitted password and confirmation values. The confirmation input name
is the main name prefixed with _.
$f = $modules->get('InputfieldPassword');
$f->name = 'pass';
$input = new WireInputData([
'pass' => 'GoodPass123!',
'_pass' => 'GoodPass123!',
]);
$f->processInput($input); Processing checks:
- required password presence
- old-password match when
requireOld > 0and a user is logged in - new/confirm password match
isValidPassword()requirements
On any error, the value is cleared and change tracking is reset.
Validates a candidate password against invalid whitespace, minimum length, and
configured character-class requirements. Returns true when valid and records
errors when invalid.
if(!$f->isValidPassword('abc')) {
foreach($f->getErrors() as $error) {
echo $sanitizer->entities($error);
}
}requireNone skips only the character-class checks. Minimum length and invalid
tab/newline whitespace are still enforced.
Associates the input with a page being edited. When the page is unpublished, the
password field becomes required. Later attempts to set collapsed are forced to
Inputfield::collapsedNo so an initial password field stays visible.
$f->setPage($userPage);getConfigInputfields() removes several inherited text-input settings from the
config UI and exposes password-specific settings:
requirementscomplexifyBanModecomplexifyFactorminlengthshowPassfor standalone usagerequireOldunmask
- Access this inputfield with
$modules->get('Inputfield.Password') - The class validates password input but does not hash or persist passwords. Persistence is handled by password fieldtypes and user password APIs.
- Client-side strength feedback depends on bundled JavaScript, but server-side validation still runs without it.
- Browser autofill is discouraged by rendering
autocomplete="new-password"in admin/logged-in contexts. - The module is permanent and cannot be uninstalled.
Source file: wire/modules/Inputfield/Inputfield
API reference: methods, properties, hooks, constants
Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the Inputfield class also inherits all the methods and properties of: InputfieldText, Inputfield, WireData and Wire.
Common
Constants
| Name | Return | Summary | |
|---|---|---|---|
| Inputfield | digit | Requirements: digit required | |
| Inputfield | letter | Requirements: letter required | |
| Inputfield | lower | Requirements: lowercase letter required | |
| Inputfield | none | Requirements: disable all above | |
| Inputfield | 0 | Require old password before changes? Auto | |
| Inputfield | -1 | Require old password before changes? No | |
| Inputfield | 1 | Require old password before changes? Yes | |
| Inputfield | other | Requirements: other character (symbol) required | |
| Inputfield | upper | Requirements: uppercase letter required |
Properties
| Name | Return | Summary | |
|---|---|---|---|
| Inputfield | string | Complexify ban mode, 'loose' or 'strict' DEFAULT: loose | |
| Inputfield | float | Complexify factor, lower numbers enable simpler passwords DEFAULT: 0.7 | |
| Inputfield | string | Label for password confirm placeholder. DEFAULT: Confirm | |
| Inputfield | string | Default label for field. Used when no 'label' has been set. DEFAULT: Set Password | |
| Inputfield | string | Label for new password placeholder. DEFAULT: New Password | |
| Inputfield | string | Label for old/current password placeholder. DEFAULT: Current Password | |
| Inputfield | int | Require previous password? 0=Auto, 1=Yes, -1=No DEFAULT: 0 | |
| Inputfield | array | Array of requirements (See require* constants) DEFAULT: [ 'letter', 'digit' ] | |
| Inputfield | array | Text labels used for requirements | |
| Inputfield | bool | Allow password to be rendered in renderValue and/or re-populated in form? DEFAULT: false | |
| Inputfield | bool | Allow passwords to be unmasked (i.e. show user what they entered) ? 3.0.173+ DEFAULT: false |
Additional methods and properties
In addition to the methods and properties above, Inputfield
API reference based on ProcessWire core version 3.0.269