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

67 lines
1.9 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();
2024-11-29 13:23:48 +03:00
$form->beginForm(isset($model) ? "/admin/post/edit/" . $model->id : "/admin/post", 'multipart/form-data');
2024-07-25 16:15:18 +03:00
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-11-20 16:48:13 +03:00
$entityRelations = new \kernel\EntityRelation();
2024-11-27 14:01:21 +03:00
if (!isset($model)) {
$model = new Post();
}
2024-11-25 15:17:41 +03:00
$entityRelations->renderEntityAdditionalPropertyFormBySlug("post", $model);
2024-11-20 16:48:13 +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();