Hi,I want to update the posttodistrict officer column,for the selected check box after pressing the post link in the above.for this i have used the batch menu extension in visual yii.
so this is my code,
view
<?php
$this->widget('ext.widgets.bmenu.XBatchMenu', array(
'formId'=>'accinspec-form',
'checkBoxId'=>'acc-inspec-grid-select-all',
'ajaxUpdate'=>'acc-inspec-grid', // if you want to update grid by ajax
'emptyText'=>Yii::t('ui','Please check items you would like to perform this action on!'),
'confirm'=>Yii::t('ui','Are you sure to perform this action on checked items?'),
'items'=>array(
array('label'=>Yii::t('ui','Post'),'url'=>array('updatePost')),
// array('label'=>Yii::t('ui','Make selected persons 1 year older'),'url'=>array('updateYears','op'=>'less')),
),
'htmlOptions'=>array('class'=>'actionBar'),
));
echo CHtml::beginForm('','post',array('id'=>'accinspec-form'));
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'acc-inspec-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
array(
'class'=>'CCheckBoxColumn',
'id'=>'acc_inspec_id',
),
'acc_inspec_date',
'acc_no_of_absents',
'acc_no_of_passed',
'acc_no_of_failed',
'Post_To_District_Officer',
array(
'class'=>'CButtonColumn',
),
),
));
echo CHtml::endForm();
?>
Controller
public function actionBatch()
{
$model=new AccInspec('search');
if(isset($_GET['Person']))
$model->attributes=$_GET['Person'];
$this->render('batch',array(
'model'=>$model,
));
}
/**
* Manages all models with batch menu.
*/
public function actionCmenu()
{
$model=new AccInspec('search');
if(isset($_GET['AccInspec']))
$model->attributes=$_GET['AccInspec'];
$this->render('cmenu',array(
'model'=>$model,
));
}
/**
* Lists all models.
*/
public function actionAlpha()
{
// AlphaPagination
Yii::import('ext.widgets.alphapager.XAlphaPagination');
$criteria=new CDbCriteria;
$alphaPages = new XAlphaPagination('acc_inspec_id');
$alphaPages->charSet = AccInspec::model()->getAlphaChars('acc_inspec_id');
$alphaPages->applyCondition($criteria);
// Dataprovider
$dataProvider=new CActiveDataProvider('AccInspec', array(
'criteria'=>$criteria,
'pagination'=>array(
'pageSize'=>Yii::app()->params['pageSize'],
'pageVar'=>'page',
),
'sort'=>array(
'defaultOrder'=>'acc_inspec_id',
),
));
$this->render('alpha',array(
'dataProvider'=>$dataProvider,
'alphaPages'=>$alphaPages,
));
}
/**
* Make selected persons 10 years older.
*/
public function actionUpdatePost()
{
// we only allow POST request
if(Yii::app()->request->isPostRequest)
{
$post=CpropertyValue::ensureString("Post");
$criteria=new CDbCriteria();
$criteria->addInCondition('id', $_POST['acc_inspec_id']);
var_dump( $criteria);
die;
AccInspec::model()->updateCounters(array('Post_To_District_Office'=>$post), $criteria);
// if AJAX request, we should not redirect the browser
if(!isset($_GET['ajax']))
{
if(!$this->goBack())
$this->redirect(array('batch'));
else
$this->goBack();
}
}
else
throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');
}
My Response is “Error 400’Invalid request. Please do not repeat this request again”.
Can Someone Please Help?