Hi,
I do not get the right search result in a tabular input view ( = batchUpdate), when I use a related field for search.
The search is working with "normal" fields of the table but after input of a search criteria in a related field I get all records of the data table.
I use the same search form, that I also use in /view/admin view CGridView. With CGridView I can search in each field of the form - also in related fields. Everything is working.
Therefore I assume, that the search form is ok and the search method in the model does the job.
I think, the bug must be in the controller code of my batchUpdate action. But I am not able to find the fault. By the way: The pagination works, also saving of data in that tabular input form works …
public function actionBatchUpdate()
{
$model=new Noten();
$criteria = new CDbCriteria();
if(isset($_GET['Noten'])) {
$model->unsetAttributes();
$model->attributes = $_GET['Noten'];
}
$dataProvider = $model->search();
$criteria = $dataProvider->criteria;
$count=$model->count($criteria);
$pages=new CPagination($count);
$pages->pageSize=6;
$pages->applyLimit($criteria);
$items = $dataProvider->data;
if(isset($_POST['Noten'])) {
$valid=true;
foreach($items as $i=>$item)
{
if(isset($_POST['Noten'][$i]))
$item->attributes=$_POST['Noten'][$i];
$valid=$item->validate() && $valid;
$item->save();
}
}
$this->render('batchUpdate', array(
'model' => $model,
'items' => $items,
'pages' => $pages,
));
}
Thank you for hints.