From 0b432da4bfbadfadc8cd7ca58809388264f7bfab Mon Sep 17 00:00:00 2001 From: Carsten Rose <carsten.rose@math.uzh.ch> Date: Thu, 20 Oct 2016 14:57:58 +0200 Subject: [PATCH] Documentation/UsersManual: update form.parameter.submitButtontext AbstractBuildForm.php, BuildFormBootstrap.php: Implemented alternative button at the bottom of the form. --- extension/Documentation/UsersManual/Index.rst | 12 ++++++++ extension/qfq/qfq/AbstractBuildForm.php | 17 +++++++---- extension/qfq/qfq/BuildFormBootstrap.php | 29 +++++++++++++++++-- extension/qfq/qfq/Constants.php | 1 + extension/qfq/qfq/QuickFormQuery.php | 2 ++ 5 files changed, 53 insertions(+), 8 deletions(-) diff --git a/extension/Documentation/UsersManual/Index.rst b/extension/Documentation/UsersManual/Index.rst index 5e632e754..8fda8c739 100644 --- a/extension/Documentation/UsersManual/Index.rst +++ b/extension/Documentation/UsersManual/Index.rst @@ -530,12 +530,24 @@ Field: Form.parameter +------------------------+--------+---------------------------------------------------------------------------------------------------+ | class | string | HTML div with given class, surrounding the whole form. Eg.: class=container-fluid | +------------------------+--------+---------------------------------------------------------------------------------------------------+ +| submitButtonText | string | Show save button, with the <submitButtonText> at the bottom of the form | ++------------------------+--------+---------------------------------------------------------------------------------------------------+ * Example: * maxVisiblePill = 5 * class = container-fluid +Field: Form.parameter.submitButtonText +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +* Optional +* By default this field is empty and a 'submit' button with a Bootstrap glyph 'check' symbol is rendered at the top right corner of the form. +* In case the 'submit' is needed at the bottom of the form, a <submitButtonText> can be specified. This will automatically + render the 'submit' at the bottom without a 'check' glyph symbol. Be sure to uncheck 'ShowButton: Save' + + + FormElements ------------ * Each *form* contains one or more *FormElement*. diff --git a/extension/qfq/qfq/AbstractBuildForm.php b/extension/qfq/qfq/AbstractBuildForm.php index cf36a5719..48622b410 100644 --- a/extension/qfq/qfq/AbstractBuildForm.php +++ b/extension/qfq/qfq/AbstractBuildForm.php @@ -159,8 +159,6 @@ abstract class AbstractBuildForm { // <form> if ($mode === FORM_LOAD) { $htmlHead = $this->head(); - $htmlTail = $this->tail(); - $htmlSubrecords = $this->doSubrecords(); } $filter = $this->getProcessFilter(); @@ -178,6 +176,13 @@ abstract class AbstractBuildForm { $recordId = $this->store->getVar(SIP_RECORD_ID, STORE_SIP); $htmlElements = $this->elements($recordId, $filter, 0, $json, $modeCollectFe, $htmlElementNameIdZero, $storeUse, $mode); } + + // <form> + if ($mode === FORM_LOAD) { + $htmlTail = $this->tail(); + $htmlSubrecords = $this->doSubrecords(); + } + $htmlSip = $this->buildHiddenSip($json); return ($mode === FORM_LOAD) ? $htmlHead . $htmlElements . $htmlSip . $htmlTail . $htmlSubrecords : $json; @@ -313,10 +318,6 @@ abstract class AbstractBuildForm { } - abstract public function tail(); - - abstract public function doSubrecords(); - abstract public function getProcessFilter(); /** @@ -435,6 +436,10 @@ abstract class AbstractBuildForm { abstract public function fillWrapLabelInputNote($label, $input, $note); + abstract public function tail(); + + abstract public function doSubrecords(); + /** * Create a hidden sip, based on latest STORE_SIP Values. Return complete HTML 'hidden' element. * diff --git a/extension/qfq/qfq/BuildFormBootstrap.php b/extension/qfq/qfq/BuildFormBootstrap.php index 3bc915c44..a07bad4be 100644 --- a/extension/qfq/qfq/BuildFormBootstrap.php +++ b/extension/qfq/qfq/BuildFormBootstrap.php @@ -119,6 +119,7 @@ class BuildFormBootstrap extends AbstractBuildForm { } /** + * Build Buttons panel on top right corner of form. * Simulate Submit Button: http://www.javascript-coder.com/javascript-form/javascript-form-submit.phtml * * @return string @@ -141,7 +142,7 @@ class BuildFormBootstrap extends AbstractBuildForm { } // Button: Save - if (Support::findInSet(FORM_BUTTON_SAVE, $this->formSpec['showButton'])) { + if (Support::findInSet(FORM_BUTTON_SAVE, $this->formSpec['showButton']) && $this->formSpec[F_SUBMIT_BUTTON_TEXT] === '') { $toolTip = 'Save'; if ($this->showDebugInfo) { @@ -205,6 +206,8 @@ class BuildFormBootstrap extends AbstractBuildForm { } /** + * Creates a button with the given attributes. If there is no $icon given, render the button without glyph. + * * @param $id * @param $title * @param $icon @@ -212,7 +215,16 @@ class BuildFormBootstrap extends AbstractBuildForm { * @return string */ private function buildButtonCode($id, $title, $icon, $disabled = '') { - return "<button id='$id' type='button' class='btn btn-default navbar-btn $disabled' " . Support::doAttribute('title', $title) . "><span class='glyphicon $icon'></span></button>"; + + $element = "<span class='glyphicon $icon'></span>"; + $classAdd = "navbar-btn"; + + if ($icon === '') { + $element = $title; + $classAdd = ''; + } + + return "<button id='$id' type='button' class='btn btn-default $classAdd $disabled' " . Support::doAttribute('title', $title) . ">$element</button>"; } /** @@ -308,6 +320,19 @@ class BuildFormBootstrap extends AbstractBuildForm { $formId = $this->getFormId(); + // Button Save at bottom of form - only if there is a button text given. + if ($this->formSpec[F_SUBMIT_BUTTON_TEXT] !== '') { + $buttonText = $this->formSpec[F_SUBMIT_BUTTON_TEXT]; + + $htmlElement = $this->buildButtonCode('save-button', $buttonText, ''); + + $html .= $this->wrapItem(WRAP_SETUP_LABEL, ''); + $html .= $this->wrapItem(WRAP_SETUP_INPUT, $htmlElement); + $html .= $this->wrapItem(WRAP_SETUP_NOTE, ''); + + $html = $this->wrapItem(WRAP_SETUP_ELEMENT, $html); + } + $html .= '</div> <!--class="tab-content" -->'; // <div class="tab-content"> // $html .= '<input type="submit" value="Submit">'; diff --git a/extension/qfq/qfq/Constants.php b/extension/qfq/qfq/Constants.php index 68821394b..d8d4c6de4 100644 --- a/extension/qfq/qfq/Constants.php +++ b/extension/qfq/qfq/Constants.php @@ -434,6 +434,7 @@ const GLYPH_ICON_CLOSE = 'glyphicon-remove'; const F_TABLE_NAME = 'tableName'; const F_REQUIRED_PARAMETER = 'requiredParameter'; +const F_SUBMIT_BUTTON_TEXT = 'submitButtonText'; // FORM_ELEMENT_STATI const FE_MODE_SHOW = 'show'; diff --git a/extension/qfq/qfq/QuickFormQuery.php b/extension/qfq/qfq/QuickFormQuery.php index 7ff260e52..54fcf67fb 100644 --- a/extension/qfq/qfq/QuickFormQuery.php +++ b/extension/qfq/qfq/QuickFormQuery.php @@ -351,6 +351,8 @@ class QuickFormQuery { Support::setIfNotSet($this->formSpec, F_BS_INPUT_COLUMNS, 8, ''); Support::setIfNotSet($this->formSpec, F_BS_NOTE_COLUMNS, 1, ''); + Support::setIfNotSet($this->formSpec, F_SUBMIT_BUTTON_TEXT, ''); + // Clear $this->store->setVar(SYSTEM_FORM_ELEMENT, '', STORE_SYSTEM); -- GitLab