Hi Guys,
Can you please help me out with this issue for which I cannot find any suitable topic yet.
I have a model with many fields,and I have used CJuiTabs for displaying the form in 4 different tabs.
The submit button is common for all the tabs.
The problem is with validation. If I am on 1st tab and click on submit and there is a validation error on 4th tab user will never come to know this as view will stick on tab one only. Can you please help me changing the tabs with validation error populate.
for example if error is on different tab then the tab should be changed to tab with error on click of submit.
here is my view file for more clarification.
<?php
/* @var $this OwnerController */
/* @var $model Owner */
/* @var $form CActiveForm */
?>
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'owner-form',
// Please note: When you enable ajax validation, make sure the corresponding
// controller action is handling ajax validation correctly.
// There is a call to performAjaxValidation() commented in generated controller code.
// See class documentation of CActiveForm for details on this.
'enableAjaxValidation'=>true,
'enableClientValidation'=>true,
'clientOptions'=> array(
'validateOnSubmit'=>true,
'afterValidate'=>'js:function(form, data, hasError) {if (!hasError){ $.blockUI(); return true; }}',
),
)); ?>
<?php
$tabs = array();
$tabs['User'] = array(
'id'=>'userTab',
'content'=>$this->renderPartial('_formUser', array(
'form' => $form,
'model'=>$model,
),
true),
);
$tabs['User Details'] = array(
'id'=>'userDetailsTab',
'content'=>$this->renderPartial('_formUserDetails', array(
'form' => $form,
'model'=>$model,
),
true),
);
$tabs['Contact'] = array(
'id'=>'userContactTab',
'content'=>$this->renderPartial('_formContact', array(
'form' => $form,
'model'=>$model,
),
true),
);
$tabs['Other'] = array(
'id'=>'userOtherTab',
'content'=>$this->renderPartial('_formOther', array(
'form' => $form,
'model'=>$model,
),
true),
);
$this->widget('zii.widgets.jui.CJuiTabs', array(
'tabs' => $tabs,
'options' => array(
'collapsible' => false,
),
));
?>
<div class="row buttons">
<?php echo CHtml::submitButton('Submit',array('class' => 'btn btn-success', 'id'=> "btnsubmit", 'name' => 'btnsubmit')); ?>
<?php if(Yii::app()->user->usertype == 1){ ?>
<?php echo CHtml::button('Cancel', array('class'=>'btn btn-default','onclick' => 'js:document.location.href="'.Yii::app()->baseUrl.'/'.$this->uniqueid.'/admin"')); ?>
<?php } ?>
</div>
<?php $this->endWidget(); ?>
Thanks in advance