Skip to content

Configuration

Elias Luhr edited this page Feb 17, 2022 · 2 revisions

rules

A multidimensional array of rules which will be used in the widget. These rules are not used in any form in model validation. They are used exclusively in the display of this widget.

    [
        [
            'text' => \Yii::t('password-input', 'Must include at least one number'),
            'pattern' => '/\d+/',
            'showInSummary' => true, // If the value is not set at all, it will be displayed
            'showAsBar' => false // If the value is not set at all, it will be displayed
        ]
    ]

loadRulesFromModel

Load rules based on yii\validators\RegularExpressionValidator from model rules. This only works when you use this input with the $model and $attribute value

    public function rules()
    {
        $rules = parent::rules();
        $rules[] = [
            'password',
            'required'
        ];
        $rules[] = [
            'password',
            'match',
            'pattern' => '/[0-9a-zA-Z]{8,}/',
            'message' => \Yii::t('test', 'Must have at least 8 characters')
        ];
        return $rules;
    }

buttonLabelShow & buttonLabelHide

These values are visible as described either for the button text when showing or hiding the password. The values can also contain HTML.

showPasswordByDefault

Show the password fields value. This changes the initial inputs type to text instead of password.

showShowPasswordButton

This property controls the visibility of the button that is responsible for showing or hiding the password.

layout

Control the widgets layout by this property

  • {input}: The actual input group
  • {bars}: Rule bars. One per rule
  • {summary}: List of rule texts

buttonOptions

Html attributes for toggle button

options

Html attributes for the input