public function getMatrixType()
{
- return $this->hasMany(BouquetCompositionMatrixTypeHistory::class, ['bouquet_id' => 'id'])
+ return $this->hasOne(BouquetCompositionMatrixTypeHistory::class, ['bouquet_id' => 'id'])
->andWhere(['is_active' => BouquetCompositionMatrixTypeHistory::IS_ACTIVE]);
}
public static function setData($value, $bouquetId) {
if (self::findOne(['bouquet_id' => $bouquetId])) {
- var_dump(1);die();
BouquetCompositionMatrixTypeHistory::updateAll(['date_to' => date('Y-m-d H:i:s'), 'bouquet_id' => $bouquetId, 'date_from' => null, 'is_active' => self::IS_ACTIVE]);
}
<?php
use kartik\file\FileInput;
+use kartik\select2\Select2;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\helpers\Url;
<?= Html::label('Тип матрицы', null, ['class' => 'h5 mt-2 mb-0']) ?>
</div>
<div class="col-md-7">
- <?= Html::dropDownList('matrix_type_id',
- $model && $model->matrixType ? $model->matrixType->matrix_type_id : null,
- ArrayHelper::map(MatrixType::find()->all(), 'id', 'name'),
- ['class' => 'form-control', 'prompt' => 'Тип матрицы'])
- ?>
+ <?= Select2::widget([
+ 'name' => 'matrix_type_id',
+ 'value' => isset($model->matrixType) ? $model->matrixType->matrix_type_id : null,
+ 'data' => ArrayHelper::map(MatrixType::find()->all(), 'id', 'name'),
+ 'options' => [
+ 'placeholder' => 'Тип матрицы',
+ ],
+ 'pluginOptions' => [
+ 'allowClear' => true,
+ ],
+ ]) ?>
+
</div>
</div>