I dont really understand the difference between activeTextField and texfield way to send the variable to the other page
This is what i want to do
I have a SDM and Is service SDM with
|sdm|0,n 1,1 |is_service|
||------------------- |_______|
So , is_service has a SDM_ID
i want to create a sub form of is service in the sdm page, showing the sdm.SDM_ID = is_service.SDM_ID
and i managed to do it
the problem is that now i want create a new grid in the view, showing a form where the SDM_ID selected can add a new is_service. The user will have the right to type all the variables except the is_service.SDM_ID which is by default equal to the sdm.SDM_ID selected in the index.
here is what i’ve started to do
SDM CONTROLLER
public function actionView($id)
{
$first_parent_instance=IsService::model()->find();
$this->render('view',array(
'model'=>$this->loadModel($id),
'childrecords'=>$this->getChildRecords($id),
'first_parent_instance'=>$first_parent_instance,
));
}
//return the list of is_service in sdm where sdm.sdm_id = is_service.sdm_id
public function getChildRecords($parentID)
{
$dataProvider = new CActiveDataProvider('IsService',array(
'criteria'=>array(
'with'=>array(
'relIsServiceSdm'=>array(
'together'=>true,
'alias'=>'is_service'
),
),
'condition'=>"is_service.SDM_ID='".$parentID."'",
),
));
return $dataProvider;
SDM view
<?php
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'child-grid',
'dataProvider'=>$childrecords,
'columns'=>array(
'IS_SERVICE_ID',
'TITLE',
),
));
$form=$this->beginWidget('CActiveForm', array(
'id'=>'functional-domain-form',
'enableAjaxValidation'=>false,
));
$IS_SERVICE_ID = CHTml::activeTextField($first_parent_instance,'IS_SERVICE_ID');
$SDM_ID = CHTml::hiddenField($first_parent_instance->SDM_ID,$first_parent_instance->SDM_ID);
$TITLE = CHTml::activeTextField($first_parent_instance,'TITLE');
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'child-grid',
'dataProvider'=>$first_parent_instance->search(),
'columns'=>array(
array(
'header'=>'IS_SERVICE_ID',
'value'=>"'$IS_SERVICE_ID'",
'type'=>'raw',
'htmlOptions'=>array('width'=>'20px'),
),
array(
'header'=>'SDM_ID',
'value'=>"'$SDM_ID'",
'type'=>'raw',
'htmlOptions'=>array('width'=>'20px'),
),
array(
'header'=>'TITLE',
'value'=>"'$TITLE'",
'type'=>'raw',
'htmlOptions'=>array('width'=>'20px'),
),
array(
'value'=>'CHTml::button(\'Add\', array(
\'submit\'=>Yii::app()->createUrl("isService/create", array(
"IS_SERVICE_ID"=>$data->IS_SERVICE_ID ,
"SDM_ID"=>$data->SDM_ID ,
"TITLE"=>$data->TITLE
))
))',
'type'=>'raw',
'htmlOptions'=>array('width'=>'40px'),
),
),
));
$this->endWidget();
i says me the field SDM_ID is empty…