Hi.
I have a standard form that only seems to use get (rather than post) when using ajax validation…
What makes it do this? not even sure where to look as other forms (with same setup/code) work fine…
Hi.
I have a standard form that only seems to use get (rather than post) when using ajax validation…
What makes it do this? not even sure where to look as other forms (with same setup/code) work fine…
Just take a look at CActiveForm::validate() method. If you have only one model for your form you could do it like this:
$result = array();
if(isset($_POST[get_class($model)]))
$model->attributes=$_POST[get_class($model)];
$model->validate();
foreach($model->getErrors() as $attribute=>$errors)
$result[CHtml::activeId($model,$attribute)]=$errors;
echo CJSON::encode($result);
Yii::app()->end();
most of the code copied from CActiveForm::validate().
Have the same problem… The above answers does not solve the problem at all… Anyone knows what the problem is?
One form works as expected with POST and no problems and seemingly identical form only would post GET which of course does not work (
Whats the problem with my solution? I’m pretty sure it should work the way I described, my code is not a complete solution, it was just a hint on how to do it.
How did you try it and what did not work?