eluhr/yii2-password-input

Password Input for Yii2

1.2.1 2023-12-07 10:10 UTC

This package is auto-updated.

Last update: 2024-10-12 11:04:30 UTC


README

Installation

composer require eluhr/yii2-password-input

Example usage

Example Password Input Loop

<?php
use eluhr\passwordInput\widgets\PasswordInput;
use yii\helpers\Html;
use yii\widgets\ActiveForm;

$form = ActiveForm::begin();
echo $form->field($model, 'password')->widget(PasswordInput::class, [
    'buttonLabelShow' => \Yii::t('password-input', 'Show'),
    'buttonLabelHide' => \Yii::t('password-input', 'Hide'),
    'layout' => "{input}\n{bars}\n{summary}",
    'loadRulesFromModel' => false,
    'rules' => [
        [
            'text' => 'Must be at least 8 characters long',
            'pattern' => '/[0-9a-zA-Z]{8,}/'
        ],
        [
            'text' => 'Must include at least one number',
            'pattern' => '/\d+/'
        ],
        [
            'text' => 'Must contain the letter "a"',
            'pattern' => '/a/',
            'showAsBar' => false
        ],
        [
            'text' => 'Must not be empty',
            'pattern' => '/.+/',
            'showInSummary' => false
        ]
    ],
    'showPasswordByDefault' => false,
    'showShowPasswordButton' => true
]);
echo Html::submitButton();
ActiveForm::end();
?>

Configuration

For configuration options please refer to the Wiki