合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
# semantic UI 在这个版本中 后台UI全面转向Semantic UI对semantic不了解的去[官网](http://www.semantic-ui.cn/)查看信息 # 改进 ~~~ public function addFormItem($name,$type,$title,$value,$coulmn=1,$col_l=2,$col_d=10,$options=array()){ $item['name']=$name; $item['type']=$type; $item['title']=$title; $item['value']=$value; $item['options']=$options; $item['coulmn']=$coulmn; $item['col_l'] =$col_l; $item['col_d'] =$col_d; $this->form_items[] = $item; return $this; } //添加一行 $conf 可以为checkbox radio select提供数据 或者css //$conf 要灵活使用 text password 等可以设置为空 或者class //checkbox 数据源 样式 //radio 数据源 样式 public function addField($name,$type,$title,$class='',$conf=''){ $field['name'] = $name; $field['type']=$type; $field['title'] = $title; $field['conf']=$conf; $field['class']=$class; $this->fields[] = $field; return $this; } //添加一行 含有多个元素 //这里注意U区别 public function addFields($name,$type,$conf=array(),$class=''){ //$name 为标识符!一行多列 这又不同 $field['name']=$name; $field['type']='fields'; $field['title'] = '';//无用参数 $field['class']=$class; $field['conf']=''; foreach ($conf as $key => $value) { $inlinefield['name'] = $value[0]; $inlinefield['type'] = $value[1]; $inlinefield['title'] = $value[2]; $inlinefield['conf'] =$value[3]; $inlinefield['class'] =$value[3]; $inlinefield['id'] = $field['name'];//设置标记 $inlinefields[] = $inlinefield; } $field['conf']=$inlinefields; // $this->$inlinefields[]=$inlinefields; // $this->inlinefields = $inlinefields; $this->fields[] = $field; return $this; } ~~~ 主要改变的是把addFormItem 修改成addField 和 addFields addField 功能与addFormItem功能相同 做了简化 radio checkbox select 等数据源 存放在$conf中 addFields 是个巨大的突破 但是还是比较复杂 用来在一个表单中生成一行多列 ## 案例 ~~~ public function test(){ $conf1 = array( array('email','inline-text','邮箱',''), array('phone','inline-text','手机',''), // array('qq','inline-text','QQ',''), ); $conf2 = array( array('email','inline-text','邮箱',''), array('phone','inline-text','手机',''), // array('qq','inline-text','QQ',''), // array('icon','inline-text','ICON',''), ); $labelconf = array( array('name'=>'','type'=>'label','title'=>'1',array('label'=>'red empty circular')), array('name'=>'','type'=>'label','title'=>'2',array('label'=>'gray empty circular')), ); $radioconf = array( array('name'=>'like','type'=>'','title'=>'运动'), array('name'=>'like','type'=>'','title'=>'电视'), ); $jankzmaker = new \JankzMaker\Controller\admin\makerForm(); $jankzmaker->setMetaTitle('测试') ->addField('email','text','邮箱','') ->addField('passwoed','text','密码','') ->addFields('one','fields',$conf1,'inline equal width') ->addFields('two','fields',$conf2,'inline equal width') ->addField('is_agree','checkbox','同意条款','inline required') ->addField('','divider','','') ->addField('','icon-divider','And',array('divider'=>'horizontal','icon'=>'teal home')) ->addField('','labels','','',$labelconf) ->addField('','label','12') ->addField('context','textarea','说点什么吧') ->addField('like','radio','你的爱好','',$radioconf) ->display(); ~~~ 实现起来 并不简单 因此除非特殊需要 不建议使用多列 $conf 与addField 不同 哦 要注意!