form-warnnosave Creates an Active Form which will warn if the user makes changes but tries to leave the page without saving.

  1. Requirements
  2. Usage
  3. Resources

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).

Resources

3 0
8 followers
592 downloads
Yii Version: 1.1
License: MIT
Category: Validation
Developed by: Loren
Created on: May 3, 2011
Last updated: 13 years ago

Downloads

show all

Related Extensions