diff --git a/columns/ActionColumn.php b/columns/ActionColumn.php new file mode 100644 index 0000000..d087f62 --- /dev/null +++ b/columns/ActionColumn.php @@ -0,0 +1,34 @@ +field; + if ($this->columnTemplate instanceof \Closure){ + $options = call_user_func($this->columnTemplate, $model); + return $options; + }else{ + return str_replace('{item}', Html::a($model->$fieldName, '#', $this->linkOptions), $this->columnTemplate); + } + + } + + + + } \ No newline at end of file diff --git a/controllers/OrderController.php b/controllers/OrderController.php index 0dbfde4..d830d42 100755 --- a/controllers/OrderController.php +++ b/controllers/OrderController.php @@ -4,6 +4,7 @@ use artbox\catalog\models\Variant; use artbox\core\admin\actions\Index; + use artbox\order\columns\ActionColumn; use artbox\order\labels\models\Delivery; use artbox\order\labels\models\Label; use artbox\order\models\OrderProduct; @@ -70,7 +71,15 @@ 'name' => [ 'type' => Index::ACTION_COL, 'columnConfig' => [ + 'class' => ActionColumn::class, 'buttonsTemplate' => '{edit}{delete}', + 'columnTemplate' => function (Order $model){ + if (empty($model->name)){ + return "(не указано)"; + }else{ + return $model->name; + } + } ], ], 'phone' => [ -- libgit2 0.21.4