diff --git a/application/admin/controller/Content.php b/application/admin/controller/Content.php index 2eb0e9a8..7a70b937 100644 --- a/application/admin/controller/Content.php +++ b/application/admin/controller/Content.php @@ -196,11 +196,13 @@ class Content extends Admin { } //获得数组的第一条数组 - $first_key = array_keys($field_group); - $rows = model('Attribute')->where($map)->order('group_id asc, sort asc')->select(); + $rows = model('Attribute')->getFieldlist($map, 'id'); if (!empty($rows)) { foreach ($rows as $key => $value) { - $fields[$field_group[$value['group_id']]][] = $value; + $list[$value['group_id']][] = $value; + } + foreach ($field_group as $key => $value) { + $fields[$value] = isset($list[$key]) ? $list[$key] : array(); } }else{ $fields = array(); diff --git a/application/admin/controller/Model.php b/application/admin/controller/Model.php index fbee84c1..7fe0ce72 100644 --- a/application/admin/controller/Model.php +++ b/application/admin/controller/Model.php @@ -53,7 +53,7 @@ class Model extends Admin { action_log('add_model', 'model', $result, session('auth_user.uid')); $this->success('创建成功!', url('admin/model/index')); }else{ - return $this->error($this->model->getError()); + return $this->error($this->model->getError() ? $this->model->getError() : '模型标识为保留名称!'); } }else{ $this->setMeta('新增模型'); @@ -78,12 +78,16 @@ class Model extends Admin { }else{ $info = $this->model->where('id', $request->param('id'))->find(); + $field_group = parse_config_attr($info['attribute_group']); //获取字段列表 $rows = db('Attribute')->where('model_id', $request->param('id'))->where('is_show', 1)->order('group_id asc, sort asc')->select(); if ($rows) { // 梳理属性的可见性 foreach ($rows as $key => $field) { - $fields[$field['group_id']][] = $field; + $list[$field['group_id']][] = $field; + } + foreach ($field_group as $key => $value) { + $fields[$value] = isset($list[$key]) ? $list[$key] : array(); } }else{ $fields = array(); diff --git a/application/admin/fields.php b/application/admin/fields.php new file mode 100644 index 00000000..2ad08806 --- /dev/null +++ b/application/admin/fields.php @@ -0,0 +1,13 @@ + array('name' => 'title', 'title' => '标题', 'type' => 'text', 'length' => 200, 'extra' => '', 'remark' => '标题', 'is_show' => 1, 'is_must' => 1, 'value'=>''), + 'category_id' => array('name' => 'category_id', 'title' => '栏目', 'type' => 'bind', 'length' => 10, 'extra' => 'category', 'remark' => '栏目', 'is_show' => 1, 'is_must' => 1, 'value'=>'0'), + 'uid' => array('name' => 'uid', 'title' => '用户UID', 'type' => 'num', 'length' => 11, 'extra' => '', 'remark' => '用户UID', 'is_show' => 0, 'is_must' => 1, 'value'=>'0'), + 'cover_id' => array('name' => 'cover_id', 'title' => '内容封面', 'type' => 'image', 'length' => 10, 'extra' => '', 'remark' => '内容封面', 'is_show' => 1, 'is_must' => 0, 'value'=>''), + 'description' => array('name' => 'description', 'title' => '内容描述', 'type' => 'textarea', 'length' => '', 'extra' => '', 'remark' => '内容描述', 'is_show' => 1, 'is_must' => 0, 'value'=>''), + 'status' => array('name' => 'status', 'title' => '数据状态', 'type' => 'select', 'length' => 2, 'extra' => "-1:删除\r\n0:禁用\r\n1:正常\r\n2:待审核\r\n3:草稿", 'remark' => '数据状态', 'is_show' => 1, 'is_must' => 1, 'value'=>'1'), + 'is_top' => array('name' => 'is_top', 'title' => '是否置顶', 'type' => 'bool', 'length' => 2, 'extra' => '', 'remark' => '是否置顶', 'is_show' => 0, 'is_must' => 1, 'value'=>'0'), + 'view' => array('name' => 'view', 'title' => '浏览数量', 'type' => 'num', 'length' => 11, 'extra' => '', 'remark' => '浏览数量', 'is_show' => 0, 'is_must' => 1, 'value'=>'0'), + 'update_time' => array('name' => 'update_time', 'title' => '更新时间', 'type' => 'datetime', 'length' => 11, 'extra' => '', 'remark' => '更新时间', 'is_show' => 0, 'is_must' => 1, 'value'=>'0'), + 'create_time' => array('name' => 'create_time', 'title' => '添加时间', 'type' => 'datetime', 'length' => 11, 'extra' => '', 'remark' => '添加时间', 'is_show' => 0, 'is_must' => 1, 'value'=>'0'), +); \ No newline at end of file diff --git a/application/admin/view/model/add.html b/application/admin/view/model/add.html index c3f825aa..9c92b6b7 100644 --- a/application/admin/view/model/add.html +++ b/application/admin/view/model/add.html @@ -29,6 +29,16 @@ (请输入模型的名称) +