Indeed, something changed. When i submit an empty form there is no "visible" validation at all. Nothing is diplayed no where but at least the page is not refreshed anymore and firebug tells ajax is working.
Why the error messages don’t display hence I can see this response via firebug
contact-form{"ContactForm_email":["Email is not a valid email address."],"ContactForm_verifyCode":["The verification code is incorrect."]}
Before answering you… I tried to do the same… and it works for me…
Here is what I have done…
controller
public function actionContact()
{
$model=new ContactForm;
if(isset($_POST['ajax']) && $_POST['ajax']==='contact-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
if(isset($_POST['ContactForm']))
{
$model->attributes=$_POST['ContactForm'];
if($model->validate())
{
$headers="From: {$model->email}\r\nReply-To: {$model->email}";
mail(Yii::app()->params['adminEmail'],$model->subject,$model->body,$headers);
Yii::app()->user->setFlash('contact','Thank you for contacting us. We will respond to you as soon as possible.');
$this->refresh();
}
}
$this->render('contact',array('model'=>$model));
}
Oh God ! I’ve found the trouble !!! Apparently my installation wasn’t so fresh as it seems to. I did another one just as you did. With the same tests and everything was ok !!!
I figure out that some jquery+css left overs copied from some other skeleton project was bugging the wole thing.
I’ve learn a great deal here. Next time I’ll exhaust all the possibilities of the framework before adding anything external to it !!!
You helped me a lot guys, sorry if I had you spent your time on this.