Hi
I have this code in my view:
<?php echo CHtml::beginForm(); ?>
<?php echo CHtml::textField('items_saved',$data->items_saved); ?>
<b><?php echo CHtml::encode($data->getAttributeLabel('name')); ?>:</b>
<?php echo CHtml::link(CHtml::encode($data->name),array('showItemsSavedInGrid')); ?>
<br />
<?php echo CHtml::endForm(); ?>
Now what I want to do is to send [color="#000080"]$data->items_saved[/color] which is string like ‘1000004, 1000006, 1000009’.
So when user clicks name (CHtml:link which I am trying to do) it should call showItemsSavedInGrid() with ‘1000004, 1000006, 1000009’ which I use as [color="#FF0000"]IN[/color] parameter.
showItemsSavedInGrid() looks like:
public function showItemsSavedInGrid()
{
$items_saved=$_POST['items_saved'];
$dataProvider=new CActiveDataProvider('AllItems',array(
'criteria'=>array(
// where id IN ('1000004, 1000006, 1000009')
'condition'=>'id IN ('.$items_saved.'),
),
));
//renders cGridView
$this->render('list',array(
'dataProvider'=>$dataProvider,
));
}
And on new view I have rendered cGridView with my condition where id IN (‘1000004, 1000006, 1000009’).
Anyway it seems like $_POST[‘items_saved’] is not sent to controller. Because in application.log I have:
2010/11/22 21:14:22 [error] [system.db.CDbCommand]
Error in querying SQL:
SELECT COUNT(*) FROM `AllItems` `t` WHERE id IN ()
Can I send POST data by CHtml::link? Or maybe there is other way to send string like ‘1000004, 1000006, 1000009’ by CHtml::link to the controller.
Thanks for any suggestions.