Form is not making AJAX post request
We have a controller (site/index) that renders a view (index). Index view includes a lot of content and partially renders a modal dialog form(registerForm). This form need to be validated onChange. As far as I can tell, the form is not posting an AJAX request at all. Is this the nature of an embedded modal dialog or have I missed something?
Calling controller
public function actionIndex()
{
$model = new SignupForm;
if(isset($_POST['ajax']) && $_POST['ajax']==='registrationForm')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
$this->render('index',array('model'=>$model));
}
registerForm activeForm
<?php $form = $this->beginWidget('CActiveForm', array(
'id'=>'registrationForm',
'enableAjaxValidation'=>true,
'focus'=>array($model,'firstName'),
'action'=>Yii::app()->request->baseUrl.'/index.php?r=profile/signup',
));
The action handler
[u]
[/u]
public function actionSignup()
{
$model = new SignupForm;
$this->performAjaxValidation($model);
if(isset($_POST['SignupForm']))
{
...
}
}
perfomAjaxValidation method
[u]
[/u]
protected function performAjaxValidation($model)
{
if(Yii::app()->getRequest()->getIsAjaxRequest() && isset($_POST['ajax']) && $_POST['ajax']==='registrationForm')
{
echo CActiveForm::validate(array($model));
Yii::app()->end();
}
}