How to pass $data variable into the url parameter in the WhEditableColumn?
Closed this issue · 2 comments
chaikovskyia commented
Can't figure out how to make editable columns in the WhGridView.
<?php
$this->widget('yiiwheels.widgets.grid.WhGridView',array(
'type'=>'striped bordered',
'dataProvider'=>$dataProvider,
'fixedHeader'=>true,
'columns'=>array(
'id',
array(
'name'=>'author',
),
array(
'name'=>'date',
),
array(
'name'=>'status',
'value'=>'Testimonials::getStatus($data->status)',
),
array(
'name'=>'status',
'class'=>'yiiwheels.widgets.editable.WhEditableColumn',
'editable'=>array(
'url'=>$this->createUrl('admin/testimonials/update', array('id'=>$data->id)),
'type'=>'select',
'source'=>Testimonials::getStatuses(),
'placement'=>'right',
)
),
array(
'class'=>'bootstrap.widgets.TbButtonColumn',
'htmlOptions'=>array('style'=>'width: 50px'),
),
),
'htmlOptions'=>array(
'class'=>'full-grid-view'
)
));
This line: 'url'=>$this->createUrl('admin/testimonials/update', array('id'=>$data->id))
generates an error : Undefined variable: data
tonydspaniard commented
It is obvious that $data
doesn't exists, the only thing you need to pass is the url
: 'url'=>$this->createUrl('admin/testimonials/update'),
the editable widget will handle the post of the correspondent model's id. Also, remember that you need to set the WhEditableSaver
at the controller.
mushahidh commented
@tonydspaniard How to set WhEditableSaver at the controller. No example is provided anywhere.