Exemplo n.º 1
0
 public function formdesign()
 {
     $form_id = intval(I('get.form_id'));
     if ($form_id <= 0) {
         $form_id = intval(I('post.form_id'));
     }
     if ($form_id <= 0) {
         $this->error('参数有误,请返回重试!');
     }
     $map = array('id' => $form_id, 'is_del' => 0);
     $one = $this->model()->where($map)->find();
     if (!$one) {
         $this->error('未找到表单数据,请返回重试!');
     }
     if (IS_GET) {
         $this->assign('one', $one);
         $this->display();
     } else {
         $design_content = trim($_POST['design_content']);
         import('@.Org.Formdesign');
         $formdesign = new \Formdesign();
         $parse_content = $formdesign->parse_form($design_content, $one['fields']);
         $design_content = $parse_content['template'];
         $formdesign->parse_table($form_id, $parse_content['add_fields']);
         //创建表或添加字段
         $data = array('fields' => $parse_content['fields'], 'content' => $parse_content['template'], 'content_parse' => $parse_content['parse'], 'content_data' => serialize($parse_content['data']), 'updatetime' => time());
         $map = array('id' => $form_id);
         $trans = $this->model()->where($map)->save($data);
         if (!$trans) {
             $this->error('保存失败,请重试!');
         }
         $this->upcache();
         $this->success('保存成功!', U('/demo/formdesign/form_id/' . $form_id));
     }
 }