My index page code look like(index.php):
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'policy-registration-form',
'enableClientValidation'=>true,
'clientOptions'=>array(
'validateOnSubmit'=>true,
),
));
?>
<label class="small" for="noapplicants">Number of applicants</label>
<?php
$static = array('1'=>1,'2'=>2,'3'=>3,'4'=>4,'5'=>5,'6'=>6,'7'=>7,'8'=>8,'9'=>9,'10'=>10,);
echo $form->dropDownList(
$PolicyFamilyApplicant,
'applicants_count',
$static ,
array('empty'=>Yii::t('fim','Please Select'),
'onchange'=>CHtml::ajax(array(
'type'=>'POST',
'url'=>array("policyFamilyDetails/applicantList"),
'data'=>array('applicant_count'=>'js:this.value',
'applicant_list'=>'js:$(".applicants").length',
),
'update'=>'.applicant_list'
)),
));
?>
<div id="applicant_1" class="applicants">
<h3>Main Applicant</h3>
<div class="halfCol float">
<div class="item">
<label for="firstname" class="xsmall">First Name</label>
<?php
echo $form->textField($PolicyFamilyDetails,'first_name',array('class'=>'medium'));
?>
</div>
</div>
<?php $this->endWidget(); ?>
And when i change the dropdown list value, i need to get the text field for the first_name that much time.
And my applicant_list.php file look like
<?php for ($i=$applicant_list;$i<$applicant_count;$i++) {?>
<div id="applicant_<?php echo $i+1;?>" class="applicants">
<div class="item">
<label for="firstname" class="xsmall">First Name</label>
<?php
echo $form->textField($PolicyFamilyDetails,'first_name',array('class'=>'medium'));
?>
</div>
</div>
<?php } ?>
And the controller looks like
<?php
class PolicyFamilyDetailsController extends Controller
{
public function actionIndex()
{
$PolicyFamilyDetails=new PolicyFamilyDetails;
$data['PolicyFamilyDetails']=$PolicyFamilyDetails;
$this->render('index',$data);
}
public function actionapplicantList()
{
$data=array();
$PolicyFamilyDetails=new PolicyFamilyDetails;
$data['PolicyFamilyDetails']=$PolicyFamilyDetails;
$data['applicant_list']=$_POST['applicant_list'];
$data['applicant_count']=$_POST['applicant_count'];
$this->renderPartial('applicant_list',$data);
}
}
?>
And when I change the dropdown value, i am getting an error like:
Fatal error: Call to a member function textField() on a non-object in /var/www/html/dev3/protected/views/policyFamilyDetails/applicant_list.php on line 10
its due to the $form object. How can I pass $form object in index.php to application_list.php?