Creates an Active Form which will warn if the user makes changes but tries to leave the page without saving. Also, enables client side validation which will not allow the form to be submitted if there are errors. You may optionally also enable validation via AJAX.
Current Version: 1.0.1
Requirements ¶
Yii 1.1.7 or more
Usage ¶
Place EActiveForm.php in your widgets folder.
Change form code to use EActiveForm
$form=$this->beginWidget(
'application.widget.EActiveForm',
array(
'id'=>'member-form',
)
);
Please note:
You can add almost any settings you want to the array for CActiveForm including: 'enableAjaxValidation'=>true if you want to use Ajax validation.
This watches for changes in inputs, selects, and textareas. If you have a button that changes your form, you should set the onclick to set changed=true and then call your function. (Eg. 'onclick' => 'changed=true;buttonClicked();', for Yii or onclick="changed=true;buttonClicked();" if you are writing the HTML)
This will not work if you disable client side validation or change any of the following in the clientOptions array validateOnSubmit (set to true) or afterValidate (set to a function).
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.