初始化文档模型的栏目选择为树形

This commit is contained in:
2020-04-27 18:59:14 +08:00
parent 2482e6f304
commit 6449d628f7

View File

@@ -17,7 +17,7 @@ class Model extends \think\Model{
protected $auto = ['update_time'];
protected $insert = ['name', 'create_time', 'status' => 1, 'list_grid' => "id:ID\r\ntitle:标题\r\ncreate_time:添加时间\r\nupdate_time:更新时间"];
protected $type = array(
'id' => 'integer'
'id' => 'integer',
);
protected static function onBeforeInsert($data) {
@@ -39,7 +39,7 @@ class Model extends \think\Model{
$data = $data->toArray();
$fields = [
'title' => ['name' => 'title', 'title' => '标题', 'type' => 'text', 'length' => 200, 'extra' => '', 'remark' => '标题', 'is_show' => 1, 'is_must' => 1, 'value' => ''],
'category_id' => ['name' => 'category_id', 'title' => '栏目', 'type' => 'bind', 'length' => 10, 'extra' => 'category', 'remark' => '栏目', 'is_show' => 1, 'is_must' => 1, 'value'=>'0'],
'category_id' => ['name' => 'category_id', 'title' => '栏目', 'type' => 'bind', 'length' => 10, 'extra' => 'category:tree', 'remark' => '栏目', 'is_show' => 1, 'is_must' => 1, 'value' => '0'],
'uid' => ['name' => 'uid', 'title' => '用户UID', 'type' => 'num', 'length' => 11, 'extra' => '', 'remark' => '用户UID', 'is_show' => 0, 'is_must' => 1, 'value' => '0'],
'cover_id' => ['name' => 'cover_id', 'title' => '内容封面', 'type' => 'image', 'length' => 10, 'extra' => '', 'remark' => '内容封面', 'is_show' => 1, 'is_must' => 0, 'value' => ''],
'description' => ['name' => 'description', 'title' => '内容描述', 'type' => 'textarea', 'length' => '', 'extra' => '', 'remark' => '内容描述', 'is_show' => 1, 'is_must' => 0, 'value' => ''],
@@ -56,7 +56,7 @@ class Model extends \think\Model{
if ($data['is_doc']) {
$fields[$key]['model_id'] = $data['id'];
} else {
if (in_array($key, array('uid', 'status', 'view', 'create_time', 'update_time'))) {
if (in_array($key, ['uid', 'title', 'status', 'view', 'create_time', 'update_time'])) {
$fields[$key]['model_id'] = $data['id'];
} else {
unset($fields[$key]);