_team_form.php 5.64 KB
<?php
    /**
     * @var Team     $team
     * @var string[] $department
     * @var string[] $country
     */
    use common\components\Request;
    use common\models\Team;
    use common\modules\file\widgets\ImageUploader;
    use kartik\select2\Select2;
    use yii\helpers\Html;
    use yii\helpers\Url;
    use yii\web\JsExpression;
    use yii\widgets\ActiveForm;

    $this->title = 'Команда';
    $this->params[ 'breadcrumbs' ][] = $this->title;
?>
<div class="login-left-column-title"><?= $this->title ?></div>
<div class="login-left-column-title-two style">Редактирование:</div>

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

<div class="input-blocks-wrapper">
    <div class="input-blocks">
        <?= $form->field($team, 'lastname')
                 ->textInput([ 'class' => 'custom-input-2' ]) ?>
    </div>
</div>

<div class="input-blocks-wrapper">
    <div class="input-blocks">
        <?= $form->field($team, 'firstname')
                 ->textInput([ 'class' => 'custom-input-2' ]) ?>
    </div>
</div>

<div class="input-blocks-wrapper">
    <div class="input-blocks">
        <?= $form->field($team, 'middlename')
                 ->textInput([ 'class' => 'custom-input-2' ]) ?>
    </div>
</div>

<div class="input-blocks-wrapper">
    <div class="input-blocks">
        <?= $form->field($team, 'link')
                 ->hint('Пример: ' . $_SERVER[ 'HTTP_HOST' ] . '/performer/common/1')
                 ->textInput([ 'class' => 'custom-input-2' ]) ?>
    </div>
</div>

<div class="input-blocks-wrapper">
    <div class="input-blocks">
        <?= $form->field($team, 'position')
                 ->textInput([ 'class' => 'custom-input-2' ]) ?>
    </div>
</div>

<div class="input-blocks-wrapper admn-select-company">
    <div class="input-blocks">
        <?= $form->field($team, 'department_id')
                 ->dropDownList($department, [ 'prompt' => 'Выберите отдел' ]) ?>
    </div>
</div>

<div class="input-blocks-wrapper">
    <div class="input-blocks">
        <?= $form->field($team, 'experience_from', [ 'template' => "{label},<span style='font-weight: 700;font-size: 13px'>лет</span><br /><span class='admn-input-txt' style='margin-right: 10px'>с</span>{input}<span class='admn-input-txt' style='margin-left: 10px'>года</span> \n{hint}\n{error}" ])
                 ->textInput([
                     'class' => 'custom-input-2 custom-input-2-date',
                     'type'  => 'number',
                     'min'   => 1950,
                     'max'   => date('Y'),
                 ]) ?>
    </div>
</div>

<div class="input-blocks-wrapper">
    <div class="input-blocks">
        <?= $form->field($team, 'country_id')
                 ->widget(Select2::classname(), [
                     'options'       => [ 'placeholder' => 'Выбор страны ...' ],
                     'pluginOptions' => [
                         'allowClear'         => true,
                         'minimumInputLength' => 3,
                         'ajax'               => [
                             'url'      => \yii\helpers\Url::to([ 'site/country' ]),
                             'dataType' => 'json',
                             'data'     => new JsExpression('function(params) { return {q:params.term}; }'),
                         ],
                         'escapeMarkup'       => new JsExpression('function (markup) { return markup; }'),
                         'templateResult'     => new JsExpression('function(country) { return country.text; }'),
                         'templateSelection'  => new JsExpression('function (country) { return country.text; }'),
                     ],
                 ]); ?>
    </div>
</div>

<div class="input-blocks-wrapper admin-avatar amin-team-foto">
    <?= ImageUploader::widget([
        'remover' => true,
        'model'   => $team,
        'field'   => 'photo',
        'size'    => [
            [
                'width'  => 100,
                'height' => 100,
            ],
        ],
        'multi'   => false,
        'gallery' => $team->photo,
        'name'    => 'Загрузить фото',
    ]); ?>
</div>

<div class="input-blocks-wrapper">
    <div class="admin-save-btn skills-save-btn admin-add-remove-wr style">
        <?= Html::submitButton($team->isNewRecord ? Yii::t('app', 'add') : 'Обновить', [ 'class' => 'input-blocks-wrapper button' ]) ?>
        <div class="admin-remove-note">
            <?php
                if(!$team->isNewRecord) {
                    echo Html::a(Yii::t('app', 'delete'), [
                        'accounts/team-delete',
                        'id' => $team->team_id,
                    ], [
                        'title'        => Yii::t('app', 'delete'),
                        'aria-label'   => Yii::t('app', 'delete'),
                        'data-confirm' =>  Yii::t('app', 'delete_confirm'),
                        'data-method'  => 'post',
                        'data-pjax'    => 0,
                    ]);
                }
            ?>
        </div>
        <div class="admin-back-note">
            <?= Html::a('вернуться', Request::getIsLocal(\Yii::$app->request->referrer) ? \Yii::$app->request->referrer : [ 'accounts/team' ]) ?>
        </div>
    </div>
</div>

<?php
    $form->end();
?>
<script>
    $(document).ready(
        function()
        {
            $('.input-blocks-wrapper.admn-select-company select').change(
                function()
                {
                    $(this).blur()
                }
            );
        }
    )
</script>