tg bot user

This commit is contained in:
Kavalar 2025-01-27 12:09:41 +03:00
parent b08aaec81d
commit dd28eadf79
3 changed files with 11 additions and 0 deletions

View File

@ -18,6 +18,7 @@ class CreateTgBotForm extends FormModel
public function rules(): array
{
return [
'user_id' => 'required',
'bot_id' => 'required',
'dialog_id' => 'required',
'username' => 'required',

View File

@ -16,6 +16,7 @@ class TgBotService
public function create(FormModel $form_model): false|Tgbot
{
$model = new Tgbot();
$model->user_id = $form_model->getItem('user_id');
$model->bot_id = $form_model->getItem('bot_id');
$model->dialog_id = $form_model->getItem('dialog_id');
$model->user_id = $form_model->getItem('user_id');
@ -32,6 +33,7 @@ class TgBotService
public function update(FormModel $form_model, Tgbot $model): false|Tgbot
{
$model->user_id = $form_model->getItem('user_id');
$model->bot_id = $form_model->getItem('bot_id');
$model->dialog_id = $form_model->getItem('dialog_id');
$model->user_id = $form_model->getItem('user_id');

View File

@ -8,6 +8,14 @@ use app\modules\tgbot\models\Tgbot;
$form = new \itguild\forms\ActiveForm();
$form->beginForm(isset($model) ? "/admin/tg-bot/edit/" . $model->id : "/admin/tg-bot");
$form->field(class: \itguild\forms\inputs\TextInput::class, name: "user_id", params: [
'class' => "form-control",
'placeholder' => 'User ID',
'value' => $model->user_id ?? ''
])
->setLabel("User ID")
->render();
$form->field(class: \itguild\forms\inputs\TextInput::class, name: "bot_id", params: [
'class' => "form-control",
'placeholder' => 'Bot ID',