From ee8e46e5c1dc6a73fc75701bb4983da135668ddd Mon Sep 17 00:00:00 2001
From: Carsten  Rose <carsten.rose@math.uzh.ch>
Date: Sun, 17 Jan 2016 18:08:40 +0100
Subject: [PATCH] Form.php: renamed formDef to formSpec to be more descriptive

---
 qfq/Form.php | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/qfq/Form.php b/qfq/Form.php
index 467155265..e098cb1cd 100644
--- a/qfq/Form.php
+++ b/qfq/Form.php
@@ -42,9 +42,9 @@ class Form {
 
     protected $store = null;
     protected $db = null;
-    protected $formDef = array();  // Form Definition: copy of the loaded form
-    protected $feDefAction = array(); // FormEelement Definition: all formElement.class='action' of the loaded form
-    protected $feDefNative = array(); // FormEelement Definition: all formElement.class='native' of the loaded form
+    protected $formSpec = array();  // Form Definition: copy of the loaded form
+    protected $feSpecAction = array(); // FormEelement Definition: all formElement.class='action' of the loaded form
+    protected $feSpecNative = array(); // FormEelement Definition: all formElement.class='native' of the loaded form
 
     /*
      * TODO:
@@ -89,18 +89,20 @@ class Form {
             // Form action: load or save?
             $mode = ($this->store->getVar(CLIENT_POST_SIP, STORE_CLIENT) === false) ? FORM_LOAD : FORM_SAVE;
 
-            $formName = $this->loadFormDefinition();
+            $formName = $this->loadFormSpecification();
 
             $sipFound = $this->validateForm();
             if (!$sipFound) {
                 $this->store->createSipAfterFormLoad($formName);
             }
 
+            $this->store->fillStoreTableDefinition($this->formSpec['tableName']);
+
             // TODO: replace switch() by Marschaller
             // render: FormPlain | FormBootstrap
-            switch ($this->formDef['render']) {
+            switch ($this->formSpec['render']) {
                 case 'Plain':
-                    $build = new FormBuildPlain($this->formDef, $this->feDefAction, $this->feDefNative);
+                    $build = new FormBuildPlain($this->formSpec, $this->feSpecAction, $this->feSpecNative);
                     break;
                 case 'Bootstrap':
                     //TODO: implement bootstrap rendering: FormBuildBootstrap
@@ -143,14 +145,14 @@ class Form {
      * @throws DbException
      * @throws UserException
      */
-    private function loadFormDefinition() {
+    private function loadFormSpecification() {
 
         $formName = $this->getFormName();
-        $this->formDef = $this->db->sql("SELECT * FROM Form AS f WHERE f.name LIKE ? AND f.deleted='no'", ROW_EXACT_1, [$formName]);
+        $this->formSpec = $this->db->sql("SELECT * FROM Form AS f WHERE f.name LIKE ? AND f.deleted='no'", ROW_EXACT_1, [$formName]);
 
         $sql = "SELECT * FROM FormElement AS fe WHERE fe.formId = ? AND fe.deleted='no' AND fe.class = ? AND fe.enabled='yes' ORDER BY fe.order, fe.id";
-        $this->feDefAction = $this->db->sql($sql, ROW_REGULAR, [$this->formDef["id"], 'action']);
-        $this->feDefNative = $this->db->sql($sql, ROW_REGULAR, [$this->formDef["id"], 'native']);
+        $this->feSpecAction = $this->db->sql($sql, ROW_REGULAR, [$this->formSpec["id"], 'action']);
+        $this->feSpecNative = $this->db->sql($sql, ROW_REGULAR, [$this->formSpec["id"], 'native']);
 
         return $formName;
     }
@@ -182,7 +184,7 @@ class Form {
         $r = $this->store->getVar(SIP_RECORD_ID, STORE_SIP . STORE_CLIENT);
 
         // If there is a record_id>0: EDIT else NEW
-        $mode = ($r > 0) ? $this->formDef['permitEdit'] : $this->formDef['permitNew'];
+        $mode = ($r > 0) ? $this->formSpec['permitEdit'] : $this->formSpec['permitNew'];
 
         $feUserLoggedIn = isset($GLOBALS["TSFE"]->fe_user->user["uid"]) && $GLOBALS["TSFE"]->fe_user->user["uid"] > 0;
 
@@ -213,7 +215,7 @@ class Form {
         }
 
         // Form Definition valid?
-        if( $this->formDef['multiMode'] !=='none' && $this->formDef['multiSql']==='') {
+        if ($this->formSpec['multiMode'] !== 'none' && $this->formSpec['multiSql'] === '') {
             throw new UserException("MultiMode selected, but MultiSQL missing", ERROR_MULTI_SQL_MISSING);
         }
 
-- 
GitLab