_projects_form.php 3.16 KB
<?php
    /**
     * @var Project          $project
     * @var Specialization[] $specialization
     * @var Payment[]        $payment
     * @var string[]         $projects
     */
    use common\models\Payment;
    use common\models\Project;
    use common\models\Specialization;
    use common\widgets\ImageUploader;
    use kartik\select2\Select2;
    use mihaildev\ckeditor\CKEditor;
    use yii\helpers\Html;
    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($project, 'name')
         ->textInput() ?>

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

<?= $form->field($project, 'project_pid')
         ->dropDownList($projects, [ 'prompt' => 'Родительский проект' ]) ?>

<?= $form->field($project, 'specializationInput')
         ->checkboxList($specialization) ?>

<div class="form-inline">
    Адрес:
    <?= $form->field($project, 'city')
             ->widget(Select2::classname(), [
                 'options'       => [ 'placeholder' => 'Выбор города ...' ],
                 'pluginOptions' => [
                     'allowClear'         => true,
                     'minimumInputLength' => 3,
                     'ajax'               => [
                         'url'      => \yii\helpers\Url::to([ 'site/city' ]),
                         'dataType' => 'json',
                         'data'     => new JsExpression('function(params) { return {q:params.term}; }'),
                     ],
                     'escapeMarkup'       => new JsExpression('function (markup) { return markup; }'),
                     'templateResult'     => new JsExpression('function(city) { return city.text; }'),
                     'templateSelection'  => new JsExpression('function (city) { return city.text; }'),
                 ],
             ]); ?>
    <?= $form->field($project, 'street', [ 'template' => "{label}{input}{hint}{error}" ])
             ->textInput() ?>
    <?= $form->field($project, 'house', [ 'template' => "{label}{input}{hint}{error}" ])
             ->textInput() ?>
</div>

<?= $form->field($project, 'budget')
         ->textInput() ?>

<?= $form->field($project, 'contractual')
         ->checkbox() ?>

<?= $form->field($project, 'payment_variant')
         ->radioList([
             1 => 'Без предоплаты',
             2 => 'Предоплата возможна',
         ]) ?>

<?= $form->field($project, 'paymentInput')
         ->checkboxList($payment) ?>

<?= $form->field($project, 'deadline', [ 'template' => "{label}{input} дней\n{hint}\n{error}" ])
         ->input('number') ?>

<?= $form->field($project, 'description')
         ->widget(CKEditor::className()) ?>

<?= $form->field($project, 'file')
         ->fileInput([ 'multiple' => 'multiple' ]) ?>

<?= $form->field($project, 'date_end')
         ->dropDownList([
             'День',
             'Неделю',
             'Месяц',
             'Год',
         ]) ?>

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

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