Skip to content
Snippets Groups Projects
Commit ee8e46e5 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Form.php: renamed formDef to formSpec to be more descriptive

parent 755ea8ce
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment