Created
September 9, 2016 02:38
-
-
Save melaniecarr23/022e65988244f5fb9957fdb55e94c4bb to your computer and use it in GitHub Desktop.
action editable actions function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public function actions() { | |
| // tutorial for EditableColumnAction to work found at | |
| // http://webtips.krajee.com/rapidly-setup-gridview-editable-cells-with-editable-column-action/ | |
| return ArrayHelper::merge(parent::actions(), [ | |
| 'editappt' =>[ | |
| //identifier for your editable action | |
| 'class' => EditableColumnAction::className(), | |
| // action class name | |
| 'modelClass' => Appt::className(), | |
| /* the update model class | |
| 'outputValue' => function ($model,$attribute,$key,$index) { | |
| $fmt = Yii::$app->formatter; | |
| $value = $model->$attribute; | |
| //your attribute value | |
| if ($attribute === 'buy_amount') { | |
| // selective validation by attribute | |
| return $fmt->asDecimal($value,2); | |
| //return formatted value if desired | |
| } elseif ($attribute === 'publish_date') { | |
| //selective validation by attribute | |
| return $fmt->asDate($value, 'php:Y-m-d'); | |
| // return formatted value if desired | |
| } | |
| return ''; | |
| //empty is same as $value | |
| }, | |
| 'outputMessage' => function($model,$attribute,$key,$index) { | |
| return ''; | |
| // any custom error after model save | |
| }, | |
| // 'showModelErrors' => true, | |
| //show model errors after save | |
| // 'errorOptions' => ['header' => ''] | |
| //error summary HTML options | |
| // 'postOnly' => true, | |
| // 'ajaxOnly' => true, | |
| // 'findModel' => function($id, $action) {}, | |
| // 'checkAccess' => function($action, $model) {} */ | |
| ] | |
| ]); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment