boubz09
(Tonton Maximeb)
May 22, 2012, 9:43am
1
Hello, i would like to place a texfield in a gridview to create a new element in my table with the value of a table, but i don’t know the syntax, i tried many ways of doing this, by putting " or ’ but i alaways have an error
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'child-grid',
'dataProvider'=>$parent->search(),
'columns'=>array(
array(
'name'=>'KU_ID',
'value'=>"$form->textField('$parent',KU_ID)",
),
array(
'value'=> "CHtml::submitButton('$parent->isNewRecord' ? 'Create' : 'Save')",
'type'=>'raw',
),
),
));
i dnt know is it possible or not…
this is the code for putting a Link… it needs ,‘class’=>‘CLinkColumn’,
array(
'class'=>'CLinkColumn',
'labelExpression'=>'$data->name',
'urlExpression'=>'Yii::app()->createUrl("/courses/exams/create",array("exam_group_id"=>$data->id,"id"=>$_REQUEST["id"]))',
'header'=>'Name',
'headerHtmlOptions'=>array('style'=>'color:#FF6600')
),
like that CActiveForm is for textField(),
Look this
try this way…im not sure…
or
CHtml
textfield and submitbutton are defined in CHtml …
boubz09
(Tonton Maximeb)
May 22, 2012, 11:09am
4
The problem is that i would like to keep this line
$form->textField('$parent',KU_ID),
i would like to put this form into my CGridView, but i think it is just a problem with " ’
but it also tells me there is an error because $form doesn’t have texfield method. which is false because when i use it out of the CGridView , it works perfectly
The problem is that i would like to keep this line
$form->textField('$parent',KU_ID),
i would like to put this form into my CGridView, but i think it is just a problem with " ’
but it also tells me there is an error because $form doesn’t have texfield method. which is false because when i use it out of the CGridView , it works perfectly
use like this
array(
'class'=>'CLinkColumn',
'labelExpression'=>'$data->name',
'urlExpression'=>'Yii::app()->createUrl("/courses/exams/create",array("exam_group_id"=>$data->id,"id"=>$_REQUEST["id"]))',
'header'=>'Name',
'headerHtmlOptions'=>array('style'=>'color:#FF6600')
),
refer CHtml …
try this
array(
'header'=>'Name',
'value'=>'CHTML::textField($data->id,$data->name,array(\'width\'=>20,\'maxlength\'=>3))',
'type'=>'raw',
'htmlOptions'=>array('width'=>'20px'),
),
and for Button
array(
'value'=>'CHTML::button(\'Remove\', array(\'submit\' => Yii::app()->createUrl("ur controller/action name", array("id"=>$data->id))))',
'type'=>'raw',
'htmlOptions'=>array('width'=>'40px'),
),
boubz09
(Tonton Maximeb)
May 22, 2012, 11:39am
8
I tried this , but got an error,
PHP notice
Undefined variable: parent
$this->widget('zii.widgets.grid.CGridView', array( 'id'=>'child-grid', 'dataProvider'=>$parent->search(), 'columns'=>array( array( 'name'=>'KU_ID', ), array( 'header'=>'Name', 'value'=>'CHTML::textField($parent->KU_ID,$parent->KU_ID)', 'type'=>'raw', 'htmlOptions'=>array('width'=>'20px'), ), array( 'value'=> "CHtml::submitButton('$parent->isNewRecord' ? 'Create' : 'Save')", 'type'=>'raw', ), ), ));
anyway, using this method won’t enable me to put the value into my $form variable won’t it?
boubz09
(Tonton Maximeb)
May 22, 2012, 11:46am
9
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'child-grid',
'dataProvider'=>$parent->search(),
'columns'=>array(
array(
'name'=>'KU_ID',
),
array(
'header'=>'Name',
'value'=>"CHTml::textField('$form->KU_ID','$form->KU_ID')",
'type'=>'raw',
'htmlOptions'=>array('width'=>'20px'),
),
array(
'value'=> "CHtml::submitButton('$parent->isNewRecord' ? 'Create' : 'Save')",
'type'=>'raw',
),
),
));
sorry i mean not $form, use $parent-> . . .
put a form
echo CHtml::beginForm();
.
.
.
.
.
.
echo CHtml::endForm();
then it will post to the action u specified…
use submit button code like i said earlier …
echo CHtml::beginForm();
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'child-grid',
'dataProvider'=>$parent->search(),
'columns'=>array(
array(
'header'=>'Name',
'value'=>"CHTml::textField('$parent->KU_ID','$parent->KU_ID')",
'type'=>'raw',
'htmlOptions'=>array('width'=>'20px'),
),
array(
'value'=>'CHTML::button(\'Remove\', array(\'submit\' => Yii::app()->createUrl("ur controller/action name", array("id"=>$data->id))))',
'type'=>'raw',
'htmlOptions'=>array('width'=>'40px'),
),
),
));
echo CHtml::endForm();
boubz09
(Tonton Maximeb)
May 22, 2012, 1:37pm
15
my path for the associated controler is
projet/protected/controllers/Key_userController.php
and the method i want to use is actionCreate()
do y have to do it like this?
array(
'value'=>'CHTML::button(\'Add\', array(\'submit\' => Yii::app()->createUrl("/controllers/Key_userController/actionCreate()", array("KU_ID"=>$data->KU_ID))))',
'type'=>'raw',
'htmlOptions'=>array('width'=>'40px'),
),
my path for the associated controler is
projet/protected/controllers/Key_userController.php
and the method i want to use is actionCreate()
do y have to do it like this?
array(
'value'=>'CHTML::button(\'Add\', array(\'submit\' => Yii::app()->createUrl("/controllers/Key_userController/actionCreate()", array("KU_ID"=>$data->KU_ID))))',
'type'=>'raw',
'htmlOptions'=>array('width'=>'40px'),
),
No man …
array(
'value'=>'CHTML::button(\'Add\', array(\'submit\' => Yii::app()->createUrl("Key_user/Create", array("KU_ID"=>$data->KU_ID))))',
'type'=>'raw',
'htmlOptions'=>array('width'=>'40px'),
),
boubz09
(Tonton Maximeb)
May 23, 2012, 8:46am
17
Thanks a lot,
In fact , this table have 3 fields to fill in , i would like , when the user press the button , reload the same page and add the new line i just put , how do i send multiple variable? like it?
how do i Recover the text i put in my texfield?
array(
'value'=>'CHTml::button(\'Add\', array(\'submit\' => Yii::app()->createUrl("key_user/create", array("KU_ID"=>$data->KU_ID))))',
'type'=>'raw',
'htmlOptions'=>array('width'=>'40px'),
),
the method create re direct me to the create form , but i wouldn’t like to have to re type the things i had just type in my form , how should i do?
i didnt get u…
create a button outside…remove buttons from grid view…post all textfield values at a time …