I have a page with both CActiveForm and my own complex JavaScript code which allows to enter tabular data (it is then is encoded into a string and this string is sent in submit by setting the value of a hidden field to this string).
The trouble is that if there is a validation error when submitting the form, my tabular data is lost and this is very bad.
Can we make validation without reloading the page?
I’ve uncommented $this->performAjaxValidation($model); both in create and update handler and ensured that the function performAjaxValidation() is as you’ve specified. I’ve also set in CActiveForm options:
But when I click Submit, the form nevertheless reloads (I think it reloads, because the browser window scrolls to the top of the page when I click Submit, and also because that my tabular data (see above) is lost when clicking Submit).
Is it possible to do validation without reloading the page?!
For your problem… the best solution is to not use the 4th parameter as "true"… and to register all the needed JS/CSS in the main view or at first non-ajax call…
please see this…
CControler::render() has a third parameter that if set to true returns the rendering result instead of displaying it - http://www.yiiframew…r#render-detail