_team_form.php 2.12 KB
<?php
    /**
     * @var Team     $team
     * @var string[] $department
     * @var string[] $country
     */
    use common\models\Team;
    use common\widgets\ImageUploader;
    use kartik\select2\Select2;
    use mihaildev\ckeditor\CKEditor;
    use yii\helpers\Html;
    use yii\jui\DatePicker;
    use yii\web\JsExpression;
    use yii\widgets\ActiveForm;

    $this->title = 'Мой профиль';
    $this->params[ 'breadcrumbs' ][] = $this->title;
?>
<h1><?= $this->title ?></h1>

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

<?= $form->field($team, 'lastname')
         ->textInput() ?>

<?= $form->field($team, 'firstname')
         ->textInput() ?>

<?= $form->field($team, 'middlename')
         ->textInput() ?>

<?= $form->field($team, 'link')
         ->textInput() ?>

<?= $form->field($team, 'position')
         ->textInput() ?>

<?= $form->field($team, 'department_id')
         ->dropDownList($department) ?>

<?= $form->field($team, 'experience_from', [ 'template' => "{label}, с {input} года \n{hint}\n{error}" ])
         ->input('number') ?>

<?=
    $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; }'),
        ],
    ]);
?>

<?= ImageUploader::widget([
    'model'   => $team,
    'field'   => 'photo',
    'width'   => 100,
    'height'  => 100,
    'multi'   => false,
    'gallery' => $team->photo,
    'name'    => 'Загрузить фото',
]); ?>

<?= Html::submitButton('Добавить') ?>

<?php
    $form->end();
?>