两个Yii CActiveForm Widget形式在一个页面ajax验证不起作用。 这是jquery相互矛盾的问题,请帮助我 一种形式是:
<?php
$form=$this->beginWidget('CActiveForm', array(
'id'=>'feedbackformid',
'enableAjaxValidation'=>true,
'clientOptions'=>array('validateOnSubmit'=>true)
));
&GT;
labelEx($反馈, '名'); ?&GT; 文本字段($反馈, '姓名',阵列( '类'=&GT; 'ontactable绿色')); ?&GT; 错误($反馈, '名'); ?&GT;
labelEx($反馈, '接触'); ?&GT; textField($ feedback,'contact',array('class'=&gt;'contactable-contact contactable-validate')); ?&GT; 错误($反馈, '接触'); ?&GT;
labelEx($反馈, '电子邮件'); ?&GT; textField($ feedback,'email',array('class'=&gt;'contactable-contact contactable-validate')); ?&GT; 错误($反馈, '电子邮件'); ?&GT;
labelEx($反馈, '消息'); ?&GT; textArea($ feedback,'message',array('class'=&gt;'contactable-contact contactable-validate')); ?&GT; 误差($反馈, '消息'); ?&GT;
“接触提交”)); ?&GT;
endWidget(); ?&GT;和第二种形式是
<?php
$form=$this->beginWidget('CActiveForm', array(
'id'=>'clientform',
'enableAjaxValidation'=>true,
'clientOptions'=>array('validateOnSubmit'=>true)
));
?>
<div class="grid_8">
<div class="info">
<?php echo $form->labelEx($model,'business_name'); ?>
<?php echo $form->textField($model,'business_name',array('class'=>'rounded','size'=>'22')); ?>
<?php echo $form->error($model,'business_name'); ?>
<?php echo $form->labelEx($model, 'state'); ?>
<?php echo $form->dropDownList($model,'state',CHtml::listData(States::model()->findAllByAttributes(array('approve'=>'Y')), 'state_id', 'title'),array('empty'=>'--Select State--',
'ajax' =>array(
'type'=>'POST', //request type
'beforeSend'=>'function(){$("#loadWaitNext").show();}',
'url'=>Yii::app()->createUrl('Site/DynamicCities'), //url to call.
'data'=>'js:{state: $(this).val()}',
'update'=>'#Clients_city',
'complete'=>'function(){ $("#loadWaitNext").hide();}',
'dataType'=>'html',
)
,'class'=>'rounded')); ?>
<span id="loadWaitNext" style="color:#FF0000;display:none;">Loading Wait..</span>
<?php echo $form->error($model,'state'); ?>
<?php echo $form->labelEx($model, 'city'); ?>
<?php echo $form->dropDownList($model,'city',CHtml::listData(Cities::model()->findAllByAttributes(array('approve'=>'Y')), 'city_id', 'title'),array('empty'=>'--Select City--',
'ajax' =>array(
'type'=>'POST', //request type
'beforeSend'=>'function(){$("#loadWaitNext").show();}',
'url'=>Yii::app()->createUrl('Site/DynamicLocations'), //url to call.
'data'=>'js:{city: $(this).val()}',
'update'=>'#Clients_location',
'complete'=>'function(){ $("#loadWaitNext").hide();}',
'dataType'=>'html',
)
,'class'=>'rounded')); ?>
<span id="loadWaitNext" style="color:#FF0000;display:none;">Loading Wait..</span>
<?php echo $form->error($model,'city'); ?>
<?php echo $form->labelEx($model, 'location'); ?>
<?php echo $form->dropDownList($model,'location',CHtml::listData(Locations::model()->findAllByAttributes(array('approve'=>'Y')), 'area_id', 'title'),array('empty'=>'--Select Locations--' ,'class'=>'rounded')); ?>
<?php echo $form->error($model,'location'); ?>
<?php echo $form->labelEx($model, 'contact_person'); ?>
<?php echo $form->textField($model, 'contact_person', array('class'=>'rounded')); ?>
<?php echo $form->error($model,'contact_person'); ?>
<?php echo $form->labelEx($model, 'contact_number'); ?>
<?php echo $form->textField($model, 'contact_number', array('class'=>'rounded')); ?>
<?php echo $form->error($model,'contact_number'); ?>
</div>
</div>
<div class="grid_8">
<div class="message">
<?php echo $form->labelEx($model, 'contact_email'); ?>
<?php echo $form->textField($model,'contact_email',array('class'=>'rounded')); ?>
<?php echo $form->error($model,'contact_email'); ?>
<?php echo $form->labelEx($model, 'verifyEmail'); ?>
<?php echo $form->textField($model,'verifyEmail',array('class'=>'rounded')); ?>
<?php echo $form->error($model,'verifyEmail'); ?>
<?php echo $form->labelEx($model, 'website'); ?>
<?php echo $form->textField($model,'website',array('class'=>'rounded')); ?>
<?php echo $form->error($model,'website'); ?>
<?php echo $form->labelEx($model, 'message'); ?>
<?php echo $form->textArea($model,'message',array('class'=>'rounded','rows'=>'2', 'cols'=>'2')); ?>
<?php echo $form->error($model,'message'); ?>
<?php echo CHtml::submitButton('Submit',array('id'=>'submit','class'=>'rounded sub_but', 'tabindex'=>'5')); ?>
</div>
</div>
<?php $this->endWidget(); ?>