_form.php 1.94 KB
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use yii\jui\AutoComplete;

/* @var $this yii\web\View */
/* @var $model common\modules\rubrication\models\TaxGroup */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="relation-form">

    <?php $form = ActiveForm::begin(); ?>

    <?= $form->field($model, $relation['entity1']['linked_key'])->widget(
        AutoComplete::className(), [
//        'model' => \common\modules\relation\models\Relation::className(),
        'clientOptions' => [
            'source' => \yii\helpers\Url::to(['manage/autocomplete/', 'relation_key' => $relation_key, 'entity' => 'entity1']),
            'dataType' => 'json',
            'autoFill' => true,
            'minLength' => '2',
        ],
        'options' => [
            'value' => empty($value1) ? '' : $value1,
            'class'=>'form-control',
            'placeholder' => $relation['entity1']['label']
        ]
    ]);
    ?>

    <?= $form->field($model, $relation['entity2']['linked_key'])->widget(
        AutoComplete::className(), [
//        'model' => \common\modules\relation\models\Relation::className(),
        'clientOptions' => [
            'source' => \yii\helpers\Url::to(['manage/autocomplete/', 'relation_key' => $relation_key, 'entity' => 'entity2']),
            'dataType' => 'json',
            'autoFill' => true,
            'minLength' => '2',
            'allowClear' => true,
        ],
        'options' => [
            'value' => empty($value2) ? '' : $value2,
            'class'=>'form-control',
            'placeholder' => $relation['entity2']['label']
        ]
    ]);
    ?>

    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? Yii::t('relation', 'Create') : Yii::t('relation', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>