I want to add "beforeSubmit" event to my form using [php]ActiveForm+[js]yiiActiveForm.
Ok, start from "view" (smarty):
{ActiveForm assign='f' id='myid' action=''}
{$f->field($model, 'name')}
{$f->field($model, 'name2')}
{/ActiveForm}
ActiveForm will register yii\widgets\ActiveFormAsset with "yii.activeForm.js" who has "events.beforeSubmit" possible to toggle, but how to do it?
I try to modify line:
$view->registerJs("jQuery('#$id').yiiActiveForm($attributes, $options);");
at yii\widgets\ActiveForm (I extended it) by add some "$options" items:
$options['beforeSubmit'] = new JsExpression('function() { alert("got it <img src='http://www.yiiframework.com/forum/public/style_emoticons/default/wink.gif' class='bbc_emoticon' alt=';)' />"); }');
It display at page correctly (js code without errors), but my "beforeSubmit" not toggled - nothing happens after submit form.
ps. I want to code simple form with error-reporting support and AJAX submit (with form cleaning after successed). Should I use yii\widgets\ActiveFormAsset or it is not ready yet?