ソースを参照

1.2.2 优化功能,修复bug

xaboy 7 年 前
コミット
3d505c7bd8
2 ファイル変更24 行追加3 行削除
  1. 18 0
      src/Form.php
  2. 6 3
      src/view/formScript.php

+ 18 - 0
src/Form.php

@@ -109,6 +109,8 @@ class Form
      */
      */
     protected $action = '';
     protected $action = '';
 
 
+    protected $id = '';
+
     /**
     /**
      * 提交方式
      * 提交方式
      * @var string
      * @var string
@@ -193,6 +195,22 @@ class Form
         return $this;
         return $this;
     }
     }
 
 
+    /**
+     * @return string
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * @param string $id
+     */
+    public function setId($id)
+    {
+        $this->id = $id;
+    }
+
 
 
     /**
     /**
      * @return string
      * @return string

+ 6 - 3
src/view/formScript.php

@@ -9,10 +9,11 @@
             }
             }
         });
         });
         return rule;
         return rule;
-    }, vm = new Vue;
-    return function create(el, callback) {
+    }, vm = new Vue,name = 'formBuilderExec<?= empty($form->getId()) ? '' : '_'.$form->getId() ?>';
+
+    window[name] =  function create(el, callback) {
         if (!el) el = document.body;
         if (!el) el = document.body;
-        return formCreate.create(getRule(), {
+        var $f = formCreate.create(getRule(), {
             el: el,
             el: el,
             form:<?=json_encode($form->getConfig('form'))?>,
             form:<?=json_encode($form->getConfig('form'))?>,
             row:<?=json_encode($form->getConfig('row'))?>,
             row:<?=json_encode($form->getConfig('row'))?>,
@@ -62,5 +63,7 @@
                 });
                 });
             }
             }
         });
         });
+        return $f;
     };
     };
+    return window[name];
 }());
 }());