I know I am missing one little thing but I can’t seem to see it and I am hoping a fresh pair of eyes can help.
I have created a single form that is using 3 models. Everything works with no Ajax but when I use ajax I can’t get the error summary to display. I viewed the source after submitting a form with no fields filled and the data is there but the container div style is set to display none and the data is returned in JSON.
Also no when I tab through the form I get errors for form field but no error summary when I submit and only the form fields I tabbed through are highlighted in red
What am I missing?
source after form submit
<div id="registration-form_es_" class="errorSummary" style="display: none;">
{"Users_username":["Username cannot be blank."],"Users_email":["Email cannot be blank."],
"Users_password":["Password cannot be blank."],"Users_password_confirm":["Confirm Password cannot be blank."],
"Users_email_confirm":["Confirm Email cannot be blank."],"Organizations_name":["Organization Name cannot be blank."],
"Organizations_mission_statement":["Mission Statement cannot be blank."],"Organizations_phone":["Phone cannot be blank."],
"Organizations_street_address":["Street Address cannot be blank."],"Organizations_postal_code":["Postal Code cannot be blank."],
"Organizations_city":["City cannot be blank."],"Organizations_province_id":["Province cannot be blank."],
"Contacts_organization_id":["Organization Id cannot be blank."],"Contacts_first_name":["First Name cannot be blank."],
"Contacts_last_name":["Last Name cannot be blank."],"Contacts_phone":["Phone cannot be blank."],
"Contacts_email":["Email cannot be blank."]}</div>
abbreviated view
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'registration-form',
'enableAjaxValidation'=>true,
'clientOptions'=> array('validateOnSubmit'=>true),
)); ?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<?php echo $form->errorSummary(array($um,$cm,$om)); ?>
<div class="row">
<?php echo $form->labelEx($um,'username'); ?>
<?php echo $form->textField($um,'username'); ?>
<?php echo $form->error($um,'username'); ?>
</div>
...
more fields
...
<div class="row buttons">
<?php
echo CHtml::ajaxSubmitButton('Submit', array('users/register'),array(
'type'=>'post', ));
?>
</div>
controller code
public function actionRegister()
{
$um = new Users;
$om = new Organizations;
$cm = new Contacts;
if(Yii::app()->request->isAjaxRequest)
{
echo CActiveForm::validate(array($um,$om,$cm));
Yii::app()->end();
}