add_use_field_for status

This commit is contained in:
SoHardKI 2019-07-02 16:51:33 +03:00
parent 39c7f052ee
commit 3142b2f548
4 changed files with 25 additions and 4 deletions

View File

@ -2,6 +2,7 @@
namespace backend\modules\settings\models;
use common\classes\Debug;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
@ -63,7 +64,7 @@ class StatusSearch extends Status
]);
$query->andFilterWhere(['like', 'name', $this->name]);
// Debug::dd($query->all());
return $dataProvider;
}
}

View File

@ -0,0 +1,3 @@
<?php
echo \common\models\UseStatus::getStatusesText($model->use);

View File

@ -1,7 +1,9 @@
<?php
use yii\data\ActiveDataProvider;
use yii\helpers\Html;
use yii\grid\GridView;
use yii\widgets\ListView;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\status\models\StatusSearch */
@ -24,9 +26,23 @@ $this->params['breadcrumbs'][] = $this->title;
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id',
'name',
[
'label' => 'Доп. информация',
'format' => 'raw',
'value' => function ($model) {
$dataProvider = new ActiveDataProvider([
'query' => $model->getUseStatuses(),
]);
return ListView::widget([
'dataProvider' => $dataProvider,
'itemView' => '_additional',
'layout' => "{items}",
]);
},
'headerOptions' => ['width' => '300'],
],
['class' => 'yii\grid\ActionColumn'],
],
]); ?>

View File

@ -76,8 +76,9 @@ class UseStatus extends \yii\db\ActiveRecord
/**
* @return string status text label
*/
public function getStatusesText()
public static function getStatusesText($id)
{
return $this->statuses[$this->status_id];
$model = new self();
return $model->statuses[$id];
}
}