add("id", Field::HIDDEN); $this->add("title", Field::TEXT, ["label" => "名称", "rules" => "required"]); $this->add("type_id", Field::SELECT, ["label" => "所属分类", "rules" => "required", "choices" => $this->getTypes()]); $this->add("poster", Field::TEXT, ["label" => "标题图", "rules" => "required", "attr" => [ "data-plugin" => "uploader" ]]); $this->add("video", Field::TEXT, ["label" => "视频文件", "rules" => "required", "attr" => [ "data-plugin" => "uploader" ]]); $this->add("published_at", Field::TEXT, ["label" => "发布时间", "default_value" => "", "help_block" => [ "text" => "留空表示未发布" ],"attr"=>[ "data-plugin" => "datetime-picker" ]]); $this->add('buttons', 'buttongroup', ["splitted" => true, "buttons" => [ ["label" => "保存", "attr" => ["class" => "btn btn-primary mr-1", "type" => "submit"]], ["label" => "返回", "attr" => ["class" => "btn btn-light btn-back", "type" => "button"]] ]]); } public function getTypes() { $types = TrainingType::orderBy("myindex")->pluck("name", "id")->toArray(); return $types; } }