解决分类为空时报错

This commit is contained in:
kalvin_cn
2016-12-11 17:42:48 +08:00
parent 0867a63089
commit f891af994d
2 changed files with 2 additions and 2 deletions

View File

@@ -583,6 +583,7 @@ function parse_field_attr($string) {
} }
function parse_field_bind($table, $selected = '', $model = 0) { function parse_field_bind($table, $selected = '', $model = 0) {
$list = array();
if ($table) { if ($table) {
$select = db($table); $select = db($table);
$res = $select->select(); $res = $select->select();
@@ -600,8 +601,6 @@ function parse_field_bind($table, $selected = '', $model = 0) {
$tree = new \com\Tree(); $tree = new \com\Tree();
$list = $tree->toFormatTree($list); $list = $tree->toFormatTree($list);
} }
} else {
$list = array();
} }
return $list; return $list;
} }

View File

@@ -32,6 +32,7 @@ class Attribute extends Base{
$value['option'] = parse_field_attr($value['extra']); $value['option'] = parse_field_attr($value['extra']);
} elseif ($value['type'] == 'bind') { } elseif ($value['type'] == 'bind') {
$extra = parse_field_bind($value['extra']); $extra = parse_field_bind($value['extra']);
$option = array();
foreach ($extra as $k => $v) { foreach ($extra as $k => $v) {
$option[$v['id']] = $v['title_show']; $option[$v['id']] = $v['title_show'];
} }