Hi everyone,
(I’m a newbie with yii and I’m french so excuse my english…)
I would like to make a view with a displaying of many subform
so i decided to call the CMenu widget
The main idea is that the user can select the sub form that he wants to see in this CMenu, when he selects a choice , the view loads itself by sending a variable to itself called ‘$valeur’
$this->widget('zii.widgets.CMenu',array(
'items'=>array(
array('label'=>'Key_user', 'url'=>array("/functional_domain/view&id=".$model->FUNCTIONAL_DOMAIN_ID.""),'valeur'=>"key_user"),
array('label'=>'Business_analyst', 'url'=>array("/functional_domain/view&id=".$model->FUNCTIONAL_DOMAIN_ID.""),'valeur'=>"business_analyst"),
),
));
then, i wanted to make a simple condition to display the table the user selected whith a widget like that
if( $valeur=="business_analyst")
{
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'child-grid',
'dataProvider'=>$business_analystRecords,
'columns'=>array(
'BA_ID',
'BA_NAME',
),
));
}
else if ($valeur=="key_user")
{
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'child-grid',
'dataProvider'=>$key_userRecords,
'columns'=>array(
'KU_ID',
'KY_NAME',
),
));
}
but there is an evident problem, yii tells me he can’t find this $valeur variable, i don’t know where and how to create it, here is my controler with the associated methods
(if i send the variable
public function actionView($id)
{
$first_parent_instance=Sdm::model()->find();
$this->render('view',array(
'model'=>$this->loadModel($id),
'business_analystRecords'=>$this->getBusiness_analystRecords($id),
'key_userRecords' => $this->getKey_userRecords($id),
));
}
public function getKey_userRecords($parentID)
{
$dataProvider = new CActiveDataProvider('Key_User',array(
'criteria'=>array(
'with'=>array(
'relKey_userFunctional_domain'=>array(
'together'=>true,
'alias'=>'key_user'
),
),
'condition'=>"key_user.FUNCTIONAL_DOMAIN_ID ='".$parentID."'",
),
));
return $dataProvider;
}
public function getBusiness_analystRecords($parentID)
{
$dataProvider = new CActiveDataProvider('Business_analyst',array(
'criteria'=>array(
'with'=>array(
'relBusiness_analystFunctional_domain'=>array(
'together'=>true,
'alias'=>'business_analyst'
),
),
'condition'=>"business_analyst.FUNCTIONAL_DOMAIN_ID ='".$parentID."'",
),
));
return $dataProvider;
}
if you have an idea, please, tell me. Am I just going to te wrong way?