fix_filter_balance

This commit is contained in:
SoHardKI 2019-07-05 11:25:15 +03:00
parent fbc6fd7dbe
commit bd1f4f6828
2 changed files with 8 additions and 3 deletions

View File

@ -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

View File

@ -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()