Yii2 Form Widgets
Yii2 widgets for form fields
Input widgets:
- PasswordRevealWidget
- PhoneInputWidget
- MaskedPhoneInputWidget
Validators:
- PhoneValidator
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist mrssofy/yii2-form-widgets "~2.0"
or add
"mrssofy/yii2-form-widgets": "~2.0"
to the require section of your composer.json
file.
Usage
Once the extension is installed, simply use it in your code by:
$form->field($order, 'name')->widget(NameInputWidget::class);
$form->field($order, 'phone')->widget(PhoneInputWidget::class);
$form->field($order, 'password')->widget(PasswordRevealWidget::class);
public function rules()
{
return [
[['phone'], 'required'],
[['phone'], PhoneValidator::class, 'returnLenght' => 10],
...
];
}