/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Attribute::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
use yii\helpers\ArrayHelper; use yii\helpers\Html; use yii\widgets\ActiveForm; /* @var $this yii\web\View */ /* @var $model im\eav\models\Value */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="value-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'attribute_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(Attribute::find()->asArray()->orderBy('name')->all(), 'id', 'presentation'), 'options' => ['prompt' => '']]); ?> <?php echo $form->field($model, 'value')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'presentation')->textInput(['maxlength' => true]); ?> <?php echo Html::submitButton($model->isNewRecord ? Module::t('module', 'Create') : Module::t('module', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-primary' : 'btn btn-success']); ?> <?php
<?php use im\eav\models\Attribute; use im\eav\Module; use yii\helpers\ArrayHelper; use yii\helpers\Html; use yii\widgets\ActiveForm; /* @var $this yii\web\View */ /* @var $attributes im\eav\models\AttributeValue[] */ /* @var $form ActiveForm|array */ ?> <div data-cont="fields"> <?php echo $this->render('@im/eav/backend/views/attribute/_fields', ['attributes' => $attributes, 'form' => $form]); ?> </div> <div class="form-inline"> <?php echo Html::dropDownList('attributes', null, ArrayHelper::map(Attribute::find()->asArray()->orderBy('name')->all(), 'id', 'presentation'), ['class' => 'form-control', 'data-field' => 'attributes', 'multiple' => true]); ?> <?php echo Html::button(Module::t('attribute', 'Add attribute'), ['class' => 'btn btn-primary', 'data-action' => 'add']); ?> </div> <div data-cont="temp"></div>