samdark / yii2-cookbook

Yii 2.0 Community Cookbook
1.45k stars 297 forks source link

form.yiiActiveForm('validate') cant validate without also submitting form #112

Closed nsanden closed 8 years ago

nsanden commented 8 years ago

Can't see how to do client side validation on a form without actually submitting the form.

with

form.data('yiiActiveForm').submitting = true;

it causes form to submit. can't seem to stop it.

without

form.data('yiiActiveForm').submitting = true;

it causes the form to not validate. even with:

form.yiiActiveForm('validate')
cebe commented 8 years ago

so you want to force the same validation that would be performed on form submit? This would rather be a feature request than an issue for this book because it is not possible as far as I see. What is your use case for this?

nsanden commented 8 years ago

Yes. Use case is this: User fills in form, if validation is successful, instead of submitting form, I want to run some javascript to 1) save form details in user session - probably an ajax request 2) popup a bootstrap modal to let the user login via authclient authwidget 3) after user logs in, i'll do stuff with session form details

cebe commented 8 years ago

please open this as a feature request on the repo then. it is currently not supported as far as I see.

nsanden commented 8 years ago

roger that thanks cebe