Skip to content

Latest commit

 

History

History
70 lines (48 loc) · 2.31 KB

README.md

File metadata and controls

70 lines (48 loc) · 2.31 KB

Faryshta Yii2 Disable Buttons

Latest Stable Version Total Downloads Latest Unstable Version License

Yii2 asset to automatically disable submit buttons on Yii2 ActiveForm.

Installation

The preferred way to install this extension is through composer.

Either run

composer require --prefer-dist "faryshta/yii2-disable-submit-buttons:*"

or add

"faryshta/yii2-disable-submit-buttons": "*"

to the require section of your composer.json file.

Register Asset

Register the faryshta\assets\ActiveFormDisableSubmitButonsAsset, preferably on your AppAsset dependencies

class AppAsset extends yii\web\AssetBundle
{
    public $depends = [
        'faryshta\\assets\\ActiveFormDisableSubmitButonsAsset',
        // other dependencies
    ];
}

Usage

Add css class disable-submit-buttons to your [ActiveForm] (http://www.yiiframework.com/doc-2.0/yii-widgets-activeform.html) widget.

Optionally if you want to change the text on a button, add the attribute data-disabled-text with the text to be changed.

$form = ActiveForm::begin([
    'options' => ['class' => 'disable-submit-buttons'],
    // other configurations
]);

    // inputs

    Html::submitButton('Submit', [
        // optional, will show the value of `data-disabled-text` attribute
        // while handling the validation and submit
        'data' => ['disable-text' => 'Please Wait']
    ])

$form->end();

With this the :input[type="submit"] buttons will be disabled and if the validation fails the buttons will be enabled again

License

The BSD License (BSD). Please see License File for more information.