I don’t understand sorry. The model i’m passing to the zii extension has some normal attribute and some attribute that are foreign key like categoryId or userId or todoId. Insted of passing these id to zii I want to pass the categoryName (based on categoryId), userName ( based on userId ) and todoTitle (based on todoId). How can I pass them the zii extension if these are not model’s attributes?
[size="5"]Anoter problem with zii.widgets.grid.CGridView. This is the code:[/size]
$dataProvider=new CActiveDataProvider('Todo', array(
'criteria'=>array(
'condition'=>'categoryId=:catId AND userId=:userId',
'params'=>array(':catId'=>$cat->categoryId, 'userId'=>$user->userId),
),
'pagination'=>array(
'pageSize'=>2,
),
));
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$dataProvider,
'columns'=>array(
'categoryId',
'title',
'desc',
'end',
'priorityId',
'privacy',
'url',
'location',
'address',
array(
'class'=>'CButtonColumn',
),
),
));
They create 3 buttons: view, update and delete. The problem is for the delete button. When I click it, it prompt the js dialog, I say yes and then it raise a 400 exception saing: Invalid request. Please do not repeat this request again.
This mean that Yii doesn’t make a Post request. This is the code in the controller:
public function actionDelete()
{
if(Yii::app()->request->isPostRequest)
{
// we only allow deletion via POST request
$t = Todo::model()->findByPk($_GET['id']);
$t->delete();
// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
if(!isset($_POST['ajax']))
$this->redirect(array('index'));
}
else
throw new CHttpException(400,'Invalid request. Please do not repeat this request again. its not post');
}
How can I solve it?