hello world
I have a problem… (certainly a stupid newbie problem )
I try to update a view (a form) by using ajax and renderPartial.
So i followed this : http://www.yiiframework.com/wiki/49/update-content-in-ajax-with-partialrender/
there is my problem :
In my view, I have a form with several options, In the form, I put a comboBox with 2 choices. depending of this choice, I want to show different fields, options, to fill in my form.
So I put this in my radioButton,in the formView :
<?php
echo CHtml::radioButton('btn', false, array(
value'=>'2',
'id'=>'radioAdd',
'name'=>'gestionnaireGroupe',
'uncheckValue'=>null,
'checked'=>true,
'onChange'=>CHtml::ajax(array( 'type'=>'POST',
'url'=>array("admin/UpdateAjaxFormGestionnaire"),
'update'=>'#gestionnaireCell')),
)); ?>
I declared my form above the radio button still in my formView like this :
$form=$this->beginWidget('CActiveForm', array(
'id'=>'evenement-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,
'clientOptions'=>array('validateOnSubmit'=>true),
)); ?>
then this what I have in my controller for this action :
public function actionUpdateAjaxFormGestionnaire()
{
$this->renderPartial('_ajaxContentFormGestionnaire', array(
'eventForm'=>$eventForm,
'gestionnaire'=>$gestionnaire,
), false, true);
}
and this in my _ajaxContentFormGestionnaire view file :
<td class="enableCreate">
<div class="row">
<?php echo $form->labelEx($eventForm,'Nom'); ?>
<?php echo $form->textField($eventForm,'Nom',array('size'=>50,'maxlength'=>50)); ?>
<?php echo $form->error($eventForm,'Nom'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($eventForm,'Prenom'); ?>
<?php echo $form->textField($eventForm,'Prenom',array('size'=>50,'maxlength'=>50)); ?>
<?php echo $form->error($eventForm,'Prenom'); ?>
</div>
... ...
But the problem is that the $form widget is not initialized or passed or … in the _ajax file. So I have this error :
Fatal error: Call to a member function labelEx() on a non-object in D:\WWW\VincentM\LayoutColloques\protected\views\admin\_ajaxContentFormGestionnaire.php on line 4
do you have any idea to help me? thx in advance.