/
v.bolshakov
/
AIEcosystem-Testing
Обзор
Документация
Войти
/
v.bolshakov
/
AIEcosystem-Testing
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
dev
backend/forms/server/HelpForm.php
135 строк
3 KB
Developer
Initial commit
03 авг 2026, 17:43
03 авг 2026, 17:43
7433917
Код
Авторство
О чём код?
<?php namespace backend\forms\server; use common\forms\base\ObjectIdForm; use common\helpers\GtpHelper; use common\kdf\KLanguage; use common\models\Documentation; use Yii; use yii\helpers\ArrayHelper; /** * Форма добавления документации * * @author Dmitry E. Semenov <sde.tomsk@gmail.com> * @copyright Self (c) 2021 */ class HelpForm extends ObjectIdForm { /** * Название * @var string */ public $title = null; /** * Заголовок * @var string */ public $header = null; /** * Полный текст * @var string */ public $full_text = null; /** * Порядок сортировки * @var string */ public $order_number = null; /** * @inheritdoc */ public function rules() { return ArrayHelper::merge(parent::rules(), [ [['title', 'full_text'], 'required'], [ [ 'order_number', ], 'number', ], [['title', 'full_text', 'header'], 'string'], ]); } /** * @inheritdoc */ public function attributeLabels() { return ArrayHelper::merge(parent::attributeLabels(), [ 'title' => Yii::t('app', 'Title'), 'header' => Yii::t('app', 'Head'), 'full_text' => Yii::t('app', 'Description'), 'order_number' => Yii::t('app', 'Sort order'), ]); } /** * @inheritdoc */ public function attributeHints() { return ArrayHelper::merge(parent::attributeHints(), [ 'order_number' => Yii::t('app', 'By default to the end of the list'), ]); } /** * @inheritdoc */ public function loadModel($condition) { parent::loadModel($condition); $obj = Documentation::findOne($this->oid); if ($obj) { $this->initState($obj); } } /** * @inheritdoc */ public function getPublicFields() { return ArrayHelper::merge(parent::getPublicFields(), [ 'title', 'header', 'full_text', 'order_number', ]); } /** * @inheritdoc */ protected function doSave() { $obj = Documentation::findOrNew($this->oid); $obj->setAttributes([ 'language_id' => KLanguage::ENGLISH, 'title' => $this->title, 'header' => $this->header, 'full_text' => $this->full_text, 'order_number' => $this->order_number, ]); if (!$obj->save()) { $this->addErrors($obj->errors); return false; } $this->model = $obj; return true; } }