Hi
Thanks to forums I managed how to pass $_POST data from cListView using CHtml::linkButton to controller:
_view.php:
<?php echo CHtml::beginForm(); ?>
<?php echo CHtml::hiddenField('items_saved',$data->items_saved); ?>
<?php echo CHtml::linkButton($data->name, array('submit' => array('showItemsSaved'))); ?>
<?php echo CHtml::endForm(); ?>
Then in controller I have:
public function actionShowItemsSaved()
{
$items_saved=$_POST['items_saved'];
$dataProvider=new CActiveDataProvider('ShowItems',array(
'criteria'=>array(
'condition'=>'id IN ('.$items_saved.')',
),
));
$this->render('new_view',array(
'dataProvider'=>$dataProvider,
));
}
And it works OK.
Now I would like to attach the same CHtml::linkButton (to call controller method and $_POST some form hidden data) to cGridView’s column for example:
<?php echo CHtml::beginForm(); ?>
<?php echo CHtml::hiddenField('items_saved',$data->items_saved); ?>
<?php echo CHtml::endForm(); ?>
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'saved-items-grid',
'dataProvider'=>$dataProvider,
'filter'=>$model,
'ajaxUpdate'=>false,
'columns'=>array(
array(
'name'=>'name',
'header'=>'Name',
'value'=>CHtml::linkButton(name, array('submit' => array('showItemsSaved'))),
),
),
));
?>
But I get error in the column ‘name’:
Parse error: syntax error, unexpected ‘<’ in /yiiapp/framework/base/CComponent.php(616) : eval()'d code on line 1
Any suggestions how to display CHtml::linkButton properly?
If there is also possibility to make CHtml::linkButton the whole row I am open to this proposition.
Thanks