backend/views/admin/post/form.php

54 lines
1.5 KiB
PHP
Raw Normal View History

2024-07-25 16:15:18 +03:00
<?php
/**
* @var Post $model
*/
use app\models\Post;
2024-07-26 16:09:06 +03:00
use app\models\User;
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-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: [
//$form->field(class: \itguild\forms\inputs\Select::class, name: "username", 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("Пользователи")
->setOptions(\app\services\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();