From 681c6cbff57b5a45cf602d5a546c663e7dca4469 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9D=A1=E4=B8=8D=E5=A4=9F=E5=85=88=E6=A3=AE?= <76847132@qq.com> Date: Fri, 17 Nov 2017 11:49:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E4=B8=8B=E5=8D=95=E5=9B=BE=E4=B8=8A=E4=BC=A0=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common/widget/Form.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/application/common/widget/Form.php b/application/common/widget/Form.php index 80c6e303..2aeb7e81 100644 --- a/application/common/widget/Form.php +++ b/application/common/widget/Form.php @@ -37,4 +37,27 @@ class Form { $view->assign($data); return $view->fetch('common@default/form/' . $type); } + public function showConfig($field, $info) { + $type = isset($field['type']) ? $field['type'].'_Config' : 'text'; + //类型合并 + if (in_array($type, array('string'))) { + $type = 'text'; + } + if (in_array($type, array('picture'))) { + $type = 'image'; + } + + $data = array( + 'type' => $type, + 'field' => isset($field['name']) ? $field['name'] : '', + 'value' => isset($info[$field['name']]) ? $info[$field['name']] : (isset($field['value']) ? $field['value'] : ''), + 'size' => isset($field['size']) ? $field['size'] : 12, + 'option' => isset($field['option']) ? $field['option'] : '', + ); + $no_tem = array('readonly', 'text', 'password','checkbox', 'textarea', 'select', 'bind', 'checkbox', 'radio', 'num', 'bool', 'decimal'); + $type = !in_array($type, $no_tem) ? $type : 'show'; + $view = new \think\View(); + $view->assign($data); + return $view->fetch('common@default/form/'.$type); + } } \ No newline at end of file