<?php
/**
 * @var CustomField $model
 */

use kernel\app_modules\user_custom_fields\models\CustomField;

$form = new \itguild\forms\ActiveForm();
$form->beginForm(isset($model) ? "/admin/custom_field/edit/" . $model->id : "/admin/custom_field", 'multipart/form-data');

// Пример формы:


$form->field(\itguild\forms\inputs\TextInput::class, 'slug', [
    'class' => "form-control",
    'placeholder' => 'Slug',
    'value' => $model->slug ?? ''
])
    ->setLabel("Slug")
    ->render();

$form->field(\itguild\forms\inputs\TextInput::class, 'label', [
    'class' => "form-control",
    'placeholder' => 'Название поля',
    'value' => $model->label ?? ''
])
    ->setLabel("Название поля")
    ->render();

$form->field(\itguild\forms\inputs\Select::class, 'type', [
    'class' => "form-control",
    'value' => $model->type ?? ''
])
    ->setLabel("Тип")
    ->setOptions(CustomField::getTypes())
    ->render();

$form->field(\itguild\forms\inputs\TextInput::class, 'entity', [
    'class' => "form-control",
    'placeholder' => 'Сущность',
    'value' => $model->entity ?? ''
])
    ->setLabel("Сущность")
    ->render();

$form->field(\itguild\forms\inputs\TextArea::class, 'field_options', [
    'class' => "form-control",
    'placeholder' => 'Вариант 1, Вариант2, Вариант 3',
    'value' => $model->field_options ?? ''
])
    ->setLabel("Опции поля (через запятую)")
    ->render();

$form->field(\itguild\forms\inputs\Select::class, 'status', [
    'class' => "form-control",
    'value' => $model->status ?? ''
])
    ->setLabel("Статус")
    ->setOptions(CustomField::getStatus())
    ->render();

/*
$form->field(class: \itguild\forms\inputs\Select::class, name: "user_id", params: [
    'class' => "form-control",
    'value' => $model->user_id ?? ''
])
    ->setLabel("Пользователи")
    ->setOptions(\kernel\modules\user\service\UserService::createUsernameArr())
    ->render();
*/

?>
    <div class="row">
        <div class="col-sm-2">
            <?php
            $form->field(\itguild\forms\inputs\Button::class, name: "btn-submit", params: [
                'class' => "btn btn-primary ",
                'value' => 'Отправить',
                'typeInput' => 'submit'
            ])
                ->render();
            ?>
        </div>
        <div class="col-sm-2">
            <?php
            $form->field(\itguild\forms\inputs\Button::class, name: "btn-reset", params: [
                'class' => "btn btn-warning",
                'value' => 'Сбросить',
                'typeInput' => 'reset'
            ])
                ->render();
            ?>
        </div>
    </div>
<?php
$form->endForm();
