diff --git a/backend/widgets/views/additional_fields_filter.php b/backend/widgets/views/additional_fields_filter.php index c1951d9..d596b8b 100644 --- a/backend/widgets/views/additional_fields_filter.php +++ b/backend/widgets/views/additional_fields_filter.php @@ -7,7 +7,7 @@ echo \kartik\select2\Select2::widget( [ 'model' => $model, 'attribute' => 'field_name', - 'data' => \common\models\Balance::getNameList(), + 'data' => \common\models\Balance::getNameList(\common\models\UseStatus::USE_BALANCE), 'options' => ['placeholder' => 'Выбрать параметр','class' => 'form-control'], 'pluginOptions' => [ 'allowClear' => true diff --git a/common/models/Balance.php b/common/models/Balance.php index abdba61..3f4465c 100644 --- a/common/models/Balance.php +++ b/common/models/Balance.php @@ -77,9 +77,14 @@ class Balance extends \yii\db\ActiveRecord ]; } - public static function getNameList() + public static function getNameList($type) { - return ArrayHelper::map(AdditionalFields::find()->all(),'id','name'); + + return ArrayHelper::map( + AdditionalFields::find() + ->leftJoin('use_field', 'additional_fields.id=use_field.field_id') + ->where(['use_field.use' => $type])->all(), 'id', 'name' + ); } public static function tableName()