How to implement form events

Comparing #4 with #9

Revision #9 was created by deacs deacs on Dec 2, 2015, 2:50:46 PM.

esdffds

Content

[...]
$this->registerJs($js);
```

And thats it... hope you find it useful. Its a bit confusing at first when you do not know what has just happened.

**NOTE:**
 
You can prevent the form from being submitted by returning false. Returning either true, null or undefined will cause the form to be submitted. See below:
 
 
 
```php 
$js = <<<JS
 
$('body').on('beforeSubmit', 'form#{$model->formName()}', function () {
 
 
    var form = $(this);
 
 
    if (form.find('.has-error').length) {
 
        return false;
 
    }
 
    
 
    // return undefined; // form gets submitted
 
    // return null; // form gets submitted
 
    // return true; // form gets submitted
 
    return false; // form does not get submitted
 
 
});
 
JS;
 
 
$this->registerJs($js);
 
 
```
 
> [![2amigOS!](http://www.gravatar.com/avatar/55363394d72945ff7ed312556ec041e0.png)](http://www.2amigos.us) <i>web development has never been so fun</i> [www.2amigos.us](http://www.2amigos.us)