From 6b4ca5cdcf182175ddc76ffe8f1c32bc3f29c798 Mon Sep 17 00:00:00 2001 From: Carsten Rose <carsten.rose@math.uzh.ch> Date: Thu, 28 Nov 2019 11:12:02 +0100 Subject: [PATCH] Implements #9655. Checkboxes and radios now defined with a min-width in horizontal plain mode. --- Documentation/Manual.rst | 16 ++++++++++++++++ extension/Classes/Core/AbstractBuildForm.php | 10 +++++++--- extension/Classes/Core/Constants.php | 3 +++ .../Classes/Core/Helper/HelperFormElement.php | 1 + extension/Classes/Core/QuickFormQuery.php | 3 ++- 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Documentation/Manual.rst b/Documentation/Manual.rst index 8adb88eef..823630071 100644 --- a/Documentation/Manual.rst +++ b/Documentation/Manual.rst @@ -2611,6 +2611,8 @@ Parameter +-----------------------------+--------+----------------------------------------------------------------------------------------------------------+ | requiredPosition | int | See requiredPosition_ . | +-----------------------------+--------+----------------------------------------------------------------------------------------------------------+ +| minWidth | int | See checkboxRadioMinWidth_ . | ++-----------------------------+--------+----------------------------------------------------------------------------------------------------------+ * Example: @@ -3144,6 +3146,8 @@ See also at specific *FormElement* definitions. | dataReference | string | Optional. See `applicationTest`_ | +------------------------+--------+----------------------------------------------------------------------------------------------------------+ | requiredPosition | int | See requiredPosition_ . | ++------------------------+--------+----------------------------------------------------------------------------------------------------------+ +| minWidth | int | See checkboxRadioMinWidth . | +------------------------+--------+----------------------------------------------------------------------------------------------------------+ @@ -3214,6 +3218,15 @@ extraButtonInfo will be applied. E.g. this might be `pull-right` to align the `info` button/icon on the right side below the input element. +.. _`checkboxRadioMinWidth`: + +Checkbox / Radio: minWidth +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Checkbox and Radio Elements, shown in plain horizontal mode, receives a minWidth to align them. The default is 80px and +might be defined per Form or per FormElement. + + .. _`requiredPosition`: Required Position @@ -3228,6 +3241,9 @@ The default is 'label-right'. The definition can be set per Form (=affects all FormElements) or per FormElement. + + + .. _`input-checkbox`: Type: checkbox diff --git a/extension/Classes/Core/AbstractBuildForm.php b/extension/Classes/Core/AbstractBuildForm.php index 3480af5f9..c319536c8 100644 --- a/extension/Classes/Core/AbstractBuildForm.php +++ b/extension/Classes/Core/AbstractBuildForm.php @@ -2244,6 +2244,8 @@ abstract class AbstractBuildForm { $attributeBase .= Support::doAttribute('data-load', ($formElement[FE_DYNAMIC_UPDATE] === 'yes') ? 'data-load' : ''); $attributeBase .= $this->getAttributeList($formElement, [F_FE_DATA_PATTERN_ERROR, F_FE_DATA_REQUIRED_ERROR, F_FE_DATA_MATCH_ERROR, F_FE_DATA_ERROR]); + $attributeBaseLabel = Support::doAttribute('style', 'min-width: ' . $formElement[F_FE_MIN_WIDTH] . 'px;'); + $key = HelperFormElement::prependFormElementNameCheckBoxMulti($htmlFormElementName, 'h'); $htmlHidden = $this->buildNativeHidden($key, ''); @@ -2293,7 +2295,7 @@ abstract class AbstractBuildForm { $htmlElement = Support::wrapTag('<label>', $htmlElement); } - $htmlElement = Support::wrapTag("<label class='$checkboxClass'>", $htmlElement, true); + $htmlElement = Support::wrapTag("<label class='$checkboxClass' $attributeBaseLabel>", $htmlElement, true); // control orientation if ($formElement[FE_MAX_LENGTH] > 1) { @@ -2508,6 +2510,8 @@ abstract class AbstractBuildForm { $attributeBase .= Support::doAttribute('type', $formElement[FE_TYPE]); $attributeBase .= Support::doAttribute('data-load', ($formElement[FE_DYNAMIC_UPDATE] === 'yes') ? 'data-load' : ''); + $attributeBaseLabel = Support::doAttribute('style', 'min-width: ' . $formElement[F_FE_MIN_WIDTH] . 'px;'); + $jj = 0; $orientation = ($formElement[FE_MAX_LENGTH] > 1) ? ALIGN_HORIZONTAL : ALIGN_VERTICAL; @@ -2515,7 +2519,7 @@ abstract class AbstractBuildForm { if ($formElement[FE_MODE] == FE_MODE_READONLY) { $radioClass .= ' qfq-disabled'; } - $radioOuterTag = ($orientation === ALIGN_HORIZONTAL) ? 'label' : 'div'; + $radioOuterTag = ($orientation === ALIGN_HORIZONTAL) ? "label $attributeBaseLabel" : 'div'; $br = ''; $attribute = $attributeBase; @@ -2541,7 +2545,7 @@ abstract class AbstractBuildForm { // With ALIGN_HORIZONTAL: the label causes some trouble: skip it if (($orientation === ALIGN_VERTICAL)) { - $htmlElement = Support::wrapTag('<label>', $htmlElement); + $htmlElement = Support::wrapTag("<label>", $htmlElement); } if ($formElement[FE_MAX_LENGTH] > 1) { diff --git a/extension/Classes/Core/Constants.php b/extension/Classes/Core/Constants.php index 602549ce6..030de75af 100644 --- a/extension/Classes/Core/Constants.php +++ b/extension/Classes/Core/Constants.php @@ -985,6 +985,9 @@ const F_FE_REQUIRED_POSITION_INPUT_RIGHT = 'input-right'; const F_FE_REQUIRED_POSITION_NOTE_LEFT = 'note-left'; const F_FE_REQUIRED_POSITION_NOTE_RIGHT = 'note-right'; +const F_FE_MIN_WIDTH = 'minWidth'; +const F_FE_MIN_WIDTH_DEFAULT = '80'; + const F_PARAMETER = 'parameter'; // valid for F_ and FE_ // Form columns: via parameter field diff --git a/extension/Classes/Core/Helper/HelperFormElement.php b/extension/Classes/Core/Helper/HelperFormElement.php index 6d34190ea..955098115 100644 --- a/extension/Classes/Core/Helper/HelperFormElement.php +++ b/extension/Classes/Core/Helper/HelperFormElement.php @@ -284,6 +284,7 @@ class HelperFormElement { $feSpecNative[$key][F_FE_LABEL_ALIGN] = $formSpec[F_FE_LABEL_ALIGN]; } Support::setIfNotSet($feSpecNative[$key], F_FE_REQUIRED_POSITION, $formSpec[F_FE_REQUIRED_POSITION]); + Support::setIfNotSet($feSpecNative[$key], F_FE_MIN_WIDTH, $formSpec[F_FE_MIN_WIDTH]); } return $feSpecNative; diff --git a/extension/Classes/Core/QuickFormQuery.php b/extension/Classes/Core/QuickFormQuery.php index d399b1877..4cb97acf1 100644 --- a/extension/Classes/Core/QuickFormQuery.php +++ b/extension/Classes/Core/QuickFormQuery.php @@ -1333,7 +1333,7 @@ class QuickFormQuery { /** * The named $keys will be synced between STORE_SYSTEM and $formSpec (both directions). * The per form definition has precedence over STORE_SYSTEM. - * STORE_SYSTEM if filled with the default values (config.qfq.php or if note exist than QFQ hardcoded) + * STORE_SYSTEM if filled with the default values (config.qfq.php or if not exist than QFQ hardcoded) * Copying the 'Form' definition back to the system store helps to access the values * by '{{ ...:Y}}' (system store). E.g. the value of bs-*-columns might be displayed as placeholder in the * corresponding input field. @@ -1440,6 +1440,7 @@ class QuickFormQuery { Support::setIfNotSet($formSpec, F_SESSION_TIMEOUT_SECONDS, $this->store->getVar(SYSTEM_SESSION_TIMEOUT_SECONDS, STORE_SYSTEM)); Support::setIfNotSet($formSpec, F_FE_REQUIRED_POSITION, F_FE_REQUIRED_POSITION_LABEL_RIGHT); Support::setIfNotSet($formSpec, F_MULTI_MSG_NO_RECORD, F_MULTI_MSG_NO_RECORD_TEXT); + Support::setIfNotSet($formSpec, F_FE_MIN_WIDTH, F_FE_MIN_WIDTH_DEFAULT); // In case there is no F_MODE defined on the form, check if there is one in STORE_SIP. if ($formSpec[F_MODE] == '') { -- GitLab