PHP code example of faryshta / yii2-disable-submit-buttons

1. Go to this page and download the library: Download faryshta/yii2-disable-submit-buttons library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

faryshta / yii2-disable-submit-buttons example snippets



use faryshta\disableSubmitButtons\Asset as DisableSubmitButtonAsset;

class AppAsset extends yii\web\AssetBundle
{
    public $depends = [
        DisableSubmitButtonsAsset::class,
        // other dependencies
    ];
}

$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' => ['disabled-text' => 'Please Wait']
    ])

$form->end();


$form = ActiveForm::begin([
    'id' => 'ajax-form',
    'options' => ['class' => 'disable-submit-buttons'],
]);
    echo $form->field($model, 'name');

    echo Html::submitButton('Submit', [
        'data' => ['disabled-text' => 'Validating'],
    ]);

$form->end();

$this->registerJsFile('ajax-form.js');