新增checkbox字段

This commit is contained in:
微笑涩涩的
2016-09-14 00:22:29 +08:00
parent 1b8b551213
commit 4c6db900ac

View File

@@ -1,40 +1,40 @@
<?php <?php
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ] // | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved. // | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn> // | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\common\widget; namespace app\common\widget;
/** /**
* 上传插件widget * 上传插件widget
* 用于动态调用分类信息 * 用于动态调用分类信息
*/ */
class Form { class Form {
public function show($field, $info) { public function show($field, $info) {
$type = isset($field['type']) ? $field['type'] : 'text'; $type = isset($field['type']) ? $field['type'] : 'text';
//类型合并 //类型合并
if (in_array($type, array('string'))) { if (in_array($type, array('string'))) {
$type = 'text'; $type = 'text';
} }
if (in_array($type, array('picture'))) { if (in_array($type, array('picture'))) {
$type = 'image'; $type = 'image';
} }
$data = array( $data = array(
'type' => $type, 'type' => $type,
'field' => isset($field['name']) ? $field['name'] : '', 'field' => isset($field['name']) ? $field['name'] : '',
'value' => isset($info[$field['name']]) ? $info[$field['name']] : '', 'value' => isset($info[$field['name']]) ? $info[$field['name']] : '',
'size' => isset($field['size']) ? $field['size'] : 12, 'size' => isset($field['size']) ? $field['size'] : 12,
'option' => isset($field['option']) ? $field['option'] : '', 'option' => isset($field['option']) ? $field['option'] : '',
); );
$no_tem = array('readonly', 'text', 'password', 'textarea', 'select', 'bind', 'checkbox', 'radio', 'num', 'bool', 'decimal'); $no_tem = array('readonly', 'text', 'password','checkbox', 'textarea', 'select', 'bind', 'checkbox', 'radio', 'num', 'bool', 'decimal');
$type = !in_array($type, $no_tem) ? $type : 'show'; $type = !in_array($type, $no_tem) ? $type : 'show';
$view = new \think\View(); $view = new \think\View();
$view->assign($data); $view->assign($data);
return $view->fetch('common@default/form/' . $type); return $view->fetch('common@default/form/' . $type);
} }
} }