Merge pull request !3 from 微笑涩涩的/master

This commit is contained in:
2016-09-14 13:33:02 +08:00
4 changed files with 239 additions and 229 deletions

View File

@@ -82,6 +82,12 @@ class Document extends \think\model\Merge{
$data = \think\Request::instance()->post();
if ($data !== false) {
//增加增加复选框 shu'zu数组保存
foreach($data ad $key=>$val){
if(is_array($val)){
$data[$key] = implode(',', $val);
}
}
/* 添加或新增基础内容 */
if(empty($data['id'])){ //新增数据
unset($data['id']);
@@ -109,6 +115,10 @@ class Document extends \think\model\Merge{
public function detail($id){
$data = $this->get($id);
$model_type = db('attribute')->where('model_id'=>$data['model_id'], 'type'=>array('in', 'checkbox'))->column('name');
foreach($model_type as $val){
$data->setAttr($val, explode(',', $data[$val]));
}
return $data;
}

View File

@@ -39,10 +39,10 @@
</select>
{/case}
{case value="checkbox"}
{php}$value = isset($value) ? $value : 1;{/php}
{php}$value = isset($value) && is_array($value) ? $value : array();{/php}
{volist name="option" id="item"}
<div class="checkbox-nice checkbox-inline">
<input type="checkbox" name="{$field}[]" id="{$field}-{$key}" value="{$key}" {if $key == $value}checked{/if}/>
<input type="checkbox" name="{$field}[]" id="{$field}-{$key}" value="{$key}" {if in_array($key, $value)}checked{/if}/>
<label for="{$field}-{$key}">{$item}</label>
</div>
{/volist}

View File

@@ -31,7 +31,7 @@ class Form {
'size' => isset($field['size']) ? $field['size'] : 12,
'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';
$view = new \think\View();
$view->assign($data);

0
guoyanhao.md Normal file
View File