View Code
<div class="form">
<?php
$form=$this->beginWidget('CActiveForm',
array(
'enableClientValidation'=>true,
'id'=>'attendance-form',
'action'=>array('getEmployeeData'),
'clientOptions'=>array('validateOnSubmit'=>true,'validateOnChange'=>true)
));
?>
<?php echo $form->errorSummary($model_one); ?>
<p class="note">Field with <span class="required">*</span> are required.</p>
<div class="row">
<?php echo $form->labelEx($model_one,'employee_full_name'); ?>
<?php
$this->widget('CAutoComplete',
array(
//name of the html field that will be generated
'model'=>$model_one,
'id'=>'SupervisorAttendance_employee_full_name',
'name'=>'employee_full_name',
'url'=>array('attendance/autoCompleteLookup'),
'max'=>10, //specifies the max number of items to display
'minChars'=>2,//specifies the number of chars that must be entered before autocomplete initiates a lookup
'delay'=>100, //number of milliseconds before lookup occurs
'matchCase'=>false, //match case when performing a lookup?
//any additional html attributes that go inside of the input field can be defined here
'htmlOptions'=>array('size'=>'40'),
'methodChain'=>".result(function(event,item){\$(\"#user_id\").val(item[1]);})",
)
);
echo CHtml::hiddenField('user_id');
?>
<?php echo $form->error($model_one,'employee_full_name'); ?>
</div>
<div class="row submit">
<?php echo CHtml::submitButton('Get Employee Data'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
Controller Action
public function actionGetEmployeeData($id='')
{
$model = new TblBasicEmployeeDetails;
$model_one = new SupervisorAttendance;//for model class SupervisorAttendance
if($id == ''){
// collect user input data
if(isset($_POST['AttendanceForm']))
{
echo 'inside form submit';die();
$model_one->attributes=$_POST['AttendanceForm'];
// validate user input and redirect to the previous page if valid
if($model_one->validate())
echo 'validated';die();
}else{
echo 'form not submitted';
$this->render('index',array('model'=>$model,'model_one'=>$model_one));
}
}
}
My form is not submitting…it always enters else code…but if i take the post of my hidden field i get the value…what could be wrong?Please help