コード例 #1
0
 /**
  * Called when inline edits are made from the summary grid
  * @return mixed ajax response
  * @throws ForbiddenHttpException
  */
 public function actionEditable()
 {
     $accessParams = ['student' => Student::findOne(Yii::$app->request->post('pk')), 'attribute' => Yii::$app->request->post('name')];
     if (Yii::$app->user->can('updateStudent', $accessParams)) {
         //!!! Dirty hack
         // the checklist columns don't always set post['value'], so force it
         if (!array_key_exists('value', $_POST)) {
             // should really check the name of the attribute and only set this
             // to a blank array when we know the attribute expects one.
             $_POST['value'] = [];
             Yii::$app->request->setBodyParams($_POST);
         }
         $action = new EditableAction('editable', $this, ['modelClass' => Student::className(), 'forceCreate' => false]);
         return $action->run();
     } else {
         throw new ForbiddenHttpException(Yii::t('app', 'You are not authorized to perform this action.'));
     }
 }
コード例 #2
0
 public function actions()
 {
     return array_merge(parent::actions(), ['editable' => ['class' => EditableAction::className(), 'modelClass' => User::className(), 'forceCreate' => false]]);
 }
コード例 #3
0
 public function actions()
 {
     return ['ajax-update' => ['class' => EditableAction::className(), 'modelClass' => ClientBeacons::className(), 'forceCreate' => false]];
 }