MicroFrameWork/kernel/modules/post/views/form.php

61 lines
1.7 KiB
PHP
Raw Normal View History

2024-07-25 16:15:18 +03:00
<?php
/**
* @var Post $model
*/
2024-09-06 16:53:20 +03:00
use kernel\modules\post\models\Post;
2024-07-25 16:15:18 +03:00
$form = new \itguild\forms\ActiveForm();
$form->beginForm(isset($model) ? "/admin/post/edit/" . $model->id : "/admin/post");
2024-09-26 14:47:13 +03:00
$form->field(\itguild\forms\inputs\TextInput::class, 'title', [
'class' => "form-control",
'placeholder' => 'Заголовок поста',
'value' => $model->title ?? ''
])
->setLabel("Заголовок")
->render();
2024-07-26 11:57:05 +03:00
$form->field(class: \itguild\forms\inputs\TextArea::class, name: "content", params: [
2024-07-25 16:15:18 +03:00
'class' => "form-control",
2024-07-26 11:57:05 +03:00
'placeholder' => 'Контент',
2024-07-25 16:15:18 +03:00
'rows' => '10',
2024-07-26 11:57:05 +03:00
'value' => $model->content ?? ''
2024-07-25 16:15:18 +03:00
])
->setLabel("Пост")
->render();
2024-07-26 16:09:06 +03:00
$form->field(class: \itguild\forms\inputs\Select::class, name: "user_id", params: [
2024-07-25 16:15:18 +03:00
'class' => "form-control",
2024-07-26 11:57:05 +03:00
'value' => $model->user_id ?? ''
2024-07-25 16:15:18 +03:00
])
2024-07-26 16:09:06 +03:00
->setLabel("Пользователи")
2024-09-06 16:53:20 +03:00
->setOptions(\kernel\modules\user\service\UserService::createUsernameArr())
2024-07-25 16:15:18 +03:00
->render();
2024-07-26 16:09:06 +03:00
2024-07-25 16:15:18 +03:00
?>
<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();