合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
# 生成表单 ###变量声明 ~~~ private $meta_title; private $post_url; private $form_items = array(); private $form_data = array(); private $extra_html; private $is_ajax = true; private $set_coulmn;//设置分栏 默认为一栏 private $template; ~~~ ### 模板初始化 ~~~ protected function _initialize(){ $this->template =APP_PATH.'JankzMaker/View/Admin/jankzform.html'; } ~~~ ### 设置页面标题 ~~~ public function setMetaTitle($meta_title){ $this->meta_title = $meta_title; return $this; } ~~~ ### 设置页面提交地址 ~~~ public function setUrl($post_url){ $this->post_url = $post_url; return $this; } ~~~ ###设置表单分列 ~~~ public function setCoulmn($set_coulmn = 1){ $this->set_coulmn =$set_coulmn; return $this; } ~~~ ### 设置ajax提交 ~~~ public function setAjax($is_ajax){ $this->is_ajax = $is_ajax; return $this; } ~~~ ### 设置表单元素 ~~~ public function addFormItem($name,$type,$title,$value,$coulmn=1,$options=array()){ $item['name']=$name; $item['type']=$type; $item['title']=$title; $item['value']=$value; $item['options']=$options; $item['coulmn']=$coulmn; $this->form_items[] = $item; return $this; } ~~~ ### 设置表单模板 ~~~ public function setTemplate($template){ $this->template = $template; return $this; } ~~~ ### 打印表单 ~~~ public function display(){ $this->assign('meta_title',$this->meta_title); $this->assign('post_url',$this->post_url); $this->assign('form_data',$this->form_data); $this->assign('form_items',$this->form_items); $this->assign('set_coulmn',$this->set_coulmn); $this->assign('is_ajax',$this->is_ajax); parent::display($this->template); } ~~~