From d317842dfc96a076d6a888b5b20f57502d944b23 Mon Sep 17 00:00:00 2001 From: Stefan Neufeind <typo3.neufeind@speedpartner.de> Date: Tue, 21 Nov 2017 13:05:42 +0100 Subject: [PATCH] [BUGFIX] backend formfields: Make boolean fields UI working in Edge/IE Add for/id so clicking the label toggles the checkbox. Resolves: #83040 Releases: master, 8.7, 7.6 Change-Id: I3dc08706556e1a95ddc8d96cae705ee968c48326 Reviewed-on: https://review.typo3.org/54715 Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Markus Klein <markus.klein@typo3.org> Tested-by: Markus Klein <markus.klein@typo3.org> Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl> Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de> Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de> Reviewed-by: Jigal van Hemert <jigal.van.hemert@typo3.org> Tested-by: Jigal van Hemert <jigal.van.hemert@typo3.org> --- .../Form/Element/InputColorPickerElement.php | 14 +++++++------- .../Classes/Form/Element/InputDateTimeElement.php | 14 +++++++------- .../Classes/Form/Element/InputLinkElement.php | 14 +++++++------- .../Classes/Form/Element/InputTextElement.php | 14 +++++++------- .../backend/Classes/Form/Element/TextElement.php | 14 +++++++------- 5 files changed, 35 insertions(+), 35 deletions(-) diff --git a/typo3/sysext/backend/Classes/Form/Element/InputColorPickerElement.php b/typo3/sysext/backend/Classes/Form/Element/InputColorPickerElement.php index 7463a5dfd2d7..364524d1b02e 100644 --- a/typo3/sysext/backend/Classes/Form/Element/InputColorPickerElement.php +++ b/typo3/sysext/backend/Classes/Form/Element/InputColorPickerElement.php @@ -67,7 +67,7 @@ class InputColorPickerElement extends AbstractFormElement $size = MathUtility::forceIntegerInRange($config['size'] ?: $this->defaultInputWidth, $this->minimumInputWidth, $this->maxInputWidth); $evalList = GeneralUtility::trimExplode(',', $config['eval'], true); $width = (int)$this->formMaxWidth($size); - $nullControlNameAttribute = ' name="' . htmlspecialchars('control[active][' . $table . '][' . $row['uid'] . '][' . $fieldName . ']') . '"'; + $nullControlNameEscaped = htmlspecialchars('control[active][' . $table . '][' . $row['uid'] . '][' . $fieldName . ']'); if ($config['readOnly']) { $html = []; @@ -187,9 +187,9 @@ class InputColorPickerElement extends AbstractFormElement $fullElement = []; $fullElement[] = '<div class="t3-form-field-disable"></div>'; $fullElement[] = '<div class="checkbox t3-form-field-eval-null-checkbox">'; - $fullElement[] = '<label>'; - $fullElement[] = '<input type="hidden"' . $nullControlNameAttribute . ' value="0" />'; - $fullElement[] = '<input type="checkbox"' . $nullControlNameAttribute . ' value="1"' . $checked . ' />'; + $fullElement[] = '<label for="' . $nullControlNameEscaped . '">'; + $fullElement[] = '<input type="hidden" name="' . $nullControlNameEscaped . '" value="0" />'; + $fullElement[] = '<input type="checkbox" name="' . $nullControlNameEscaped . '" id="' . $nullControlNameEscaped . '" value="1"' . $checked . ' />'; $fullElement[] = $languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.nullCheckbox'); $fullElement[] = '</label>'; $fullElement[] = '</div>'; @@ -223,9 +223,9 @@ class InputColorPickerElement extends AbstractFormElement } $fullElement = []; $fullElement[] = '<div class="checkbox t3js-form-field-eval-null-placeholder-checkbox">'; - $fullElement[] = '<label>'; - $fullElement[] = '<input type="hidden"' . $nullControlNameAttribute . ' value="' . $fallbackValue . '" />'; - $fullElement[] = '<input type="checkbox"' . $nullControlNameAttribute . ' value="1"' . $checked . $disabled . ' />'; + $fullElement[] = '<label for="' . $nullControlNameEscaped . '">'; + $fullElement[] = '<input type="hidden" name="' . $nullControlNameEscaped . '" value="' . $fallbackValue . '" />'; + $fullElement[] = '<input type="checkbox" name="' . $nullControlNameEscaped . '" id="' . $nullControlNameEscaped . '" value="1"' . $checked . $disabled . ' />'; $fullElement[] = $overrideLabel; $fullElement[] = '</label>'; $fullElement[] = '</div>'; diff --git a/typo3/sysext/backend/Classes/Form/Element/InputDateTimeElement.php b/typo3/sysext/backend/Classes/Form/Element/InputDateTimeElement.php index 4b1afdded51f..2574884c189f 100644 --- a/typo3/sysext/backend/Classes/Form/Element/InputDateTimeElement.php +++ b/typo3/sysext/backend/Classes/Form/Element/InputDateTimeElement.php @@ -68,7 +68,7 @@ class InputDateTimeElement extends AbstractFormElement $itemValue = $parameterArray['itemFormElValue']; $defaultInputWidth = 10; $evalList = GeneralUtility::trimExplode(',', $config['eval'], true); - $nullControlNameAttribute = ' name="' . htmlspecialchars('control[active][' . $table . '][' . $row['uid'] . '][' . $fieldName . ']') . '"'; + $nullControlNameEscaped = htmlspecialchars('control[active][' . $table . '][' . $row['uid'] . '][' . $fieldName . ']'); if (in_array('date', $evalList, true)) { $format = 'date'; @@ -204,9 +204,9 @@ class InputDateTimeElement extends AbstractFormElement $fullElement = []; $fullElement[] = '<div class="t3-form-field-disable"></div>'; $fullElement[] = '<div class="checkbox t3-form-field-eval-null-checkbox">'; - $fullElement[] = '<label>'; - $fullElement[] = '<input type="hidden"' . $nullControlNameAttribute . ' value="0" />'; - $fullElement[] = '<input type="checkbox"' . $nullControlNameAttribute . ' value="1"' . $checked . ' />'; + $fullElement[] = '<label for="' . $nullControlNameEscaped . '">'; + $fullElement[] = '<input type="hidden" name="' . $nullControlNameEscaped . '" value="0" />'; + $fullElement[] = '<input type="checkbox" name="' . $nullControlNameEscaped . '" id="' . $nullControlNameEscaped . '" value="1"' . $checked . ' />'; $fullElement[] = $languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.nullCheckbox'); $fullElement[] = '</label>'; $fullElement[] = '</div>'; @@ -240,9 +240,9 @@ class InputDateTimeElement extends AbstractFormElement } $fullElement = []; $fullElement[] = '<div class="checkbox t3js-form-field-eval-null-placeholder-checkbox">'; - $fullElement[] = '<label>'; - $fullElement[] = '<input type="hidden"' . $nullControlNameAttribute . ' value="' . $fallbackValue . '" />'; - $fullElement[] = '<input type="checkbox"' . $nullControlNameAttribute . ' value="1"' . $checked . $disabled . ' />'; + $fullElement[] = '<label for="' . $nullControlNameEscaped . '">'; + $fullElement[] = '<input type="hidden" name="' . $nullControlNameEscaped . '" value="' . $fallbackValue . '" />'; + $fullElement[] = '<input type="checkbox" name="' . $nullControlNameEscaped . '" id="' . $nullControlNameEscaped . '" value="1"' . $checked . $disabled . ' />'; $fullElement[] = $overrideLabel; $fullElement[] = '</label>'; $fullElement[] = '</div>'; diff --git a/typo3/sysext/backend/Classes/Form/Element/InputLinkElement.php b/typo3/sysext/backend/Classes/Form/Element/InputLinkElement.php index 93b47bcec520..5dd841cbac48 100644 --- a/typo3/sysext/backend/Classes/Form/Element/InputLinkElement.php +++ b/typo3/sysext/backend/Classes/Form/Element/InputLinkElement.php @@ -90,7 +90,7 @@ class InputLinkElement extends AbstractFormElement $evalList = GeneralUtility::trimExplode(',', $config['eval'], true); $size = MathUtility::forceIntegerInRange($config['size'] ?? $this->defaultInputWidth, $this->minimumInputWidth, $this->maxInputWidth); $width = (int)$this->formMaxWidth($size); - $nullControlNameAttribute = ' name="' . htmlspecialchars('control[active][' . $table . '][' . $row['uid'] . '][' . $fieldName . ']') . '"'; + $nullControlNameEscaped = htmlspecialchars('control[active][' . $table . '][' . $row['uid'] . '][' . $fieldName . ']'); if ($config['readOnly']) { // Early return for read only fields @@ -237,9 +237,9 @@ class InputLinkElement extends AbstractFormElement $fullElement = []; $fullElement[] = '<div class="t3-form-field-disable"></div>'; $fullElement[] = '<div class="checkbox t3-form-field-eval-null-checkbox">'; - $fullElement[] = '<label>'; - $fullElement[] = '<input type="hidden"' . $nullControlNameAttribute . ' value="0" />'; - $fullElement[] = '<input type="checkbox"' . $nullControlNameAttribute . ' value="1"' . $checked . ' />'; + $fullElement[] = '<label for="' . $nullControlNameEscaped . '">'; + $fullElement[] = '<input type="hidden" name="' . $nullControlNameEscaped . '" value="0" />'; + $fullElement[] = '<input type="checkbox" name="' . $nullControlNameEscaped . '" id="' . $nullControlNameEscaped . '" value="1"' . $checked . ' />'; $fullElement[] = $languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.nullCheckbox'); $fullElement[] = '</label>'; $fullElement[] = '</div>'; @@ -273,9 +273,9 @@ class InputLinkElement extends AbstractFormElement } $fullElement = []; $fullElement[] = '<div class="checkbox t3js-form-field-eval-null-placeholder-checkbox">'; - $fullElement[] = '<label>'; - $fullElement[] = '<input type="hidden"' . $nullControlNameAttribute . ' value="' . $fallbackValue . '" />'; - $fullElement[] = '<input type="checkbox"' . $nullControlNameAttribute . ' value="1"' . $checked . $disabled . ' />'; + $fullElement[] = '<label for="' . $nullControlNameEscaped . '">'; + $fullElement[] = '<input type="hidden" name="' . $nullControlNameEscaped . '" value="' . $fallbackValue . '" />'; + $fullElement[] = '<input type="checkbox" name="' . $nullControlNameEscaped . '" id="' . $nullControlNameEscaped . '" value="1"' . $checked . $disabled . ' />'; $fullElement[] = $overrideLabel; $fullElement[] = '</label>'; $fullElement[] = '</div>'; diff --git a/typo3/sysext/backend/Classes/Form/Element/InputTextElement.php b/typo3/sysext/backend/Classes/Form/Element/InputTextElement.php index eef65c3e20f1..66681ea5c4e5 100644 --- a/typo3/sysext/backend/Classes/Form/Element/InputTextElement.php +++ b/typo3/sysext/backend/Classes/Form/Element/InputTextElement.php @@ -70,7 +70,7 @@ class InputTextElement extends AbstractFormElement $evalList = GeneralUtility::trimExplode(',', $config['eval'], true); $size = MathUtility::forceIntegerInRange($config['size'] ?? $this->defaultInputWidth, $this->minimumInputWidth, $this->maxInputWidth); $width = (int)$this->formMaxWidth($size); - $nullControlNameAttribute = ' name="' . htmlspecialchars('control[active][' . $table . '][' . $row['uid'] . '][' . $fieldName . ']') . '"'; + $nullControlNameEscaped = htmlspecialchars('control[active][' . $table . '][' . $row['uid'] . '][' . $fieldName . ']'); if ($config['readOnly']) { // Early return for read only fields @@ -238,9 +238,9 @@ class InputTextElement extends AbstractFormElement $fullElement = []; $fullElement[] = '<div class="t3-form-field-disable"></div>'; $fullElement[] = '<div class="checkbox t3-form-field-eval-null-checkbox">'; - $fullElement[] = '<label>'; - $fullElement[] = '<input type="hidden"' . $nullControlNameAttribute . ' value="0" />'; - $fullElement[] = '<input type="checkbox"' . $nullControlNameAttribute . ' value="1"' . $checked . ' />'; + $fullElement[] = '<label for="' . $nullControlNameEscaped . '">'; + $fullElement[] = '<input type="hidden" name="' . $nullControlNameEscaped . '" value="0" />'; + $fullElement[] = '<input type="checkbox" name="' . $nullControlNameEscaped . '" id="' . $nullControlNameEscaped . '" value="1"' . $checked . ' />'; $fullElement[] = $languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.nullCheckbox'); $fullElement[] = '</label>'; $fullElement[] = '</div>'; @@ -274,9 +274,9 @@ class InputTextElement extends AbstractFormElement } $fullElement = []; $fullElement[] = '<div class="checkbox t3js-form-field-eval-null-placeholder-checkbox">'; - $fullElement[] = '<label>'; - $fullElement[] = '<input type="hidden"' . $nullControlNameAttribute . ' value="' . $fallbackValue . '" />'; - $fullElement[] = '<input type="checkbox"' . $nullControlNameAttribute . ' value="1"' . $checked . $disabled . ' />'; + $fullElement[] = '<label for="' . $nullControlNameEscaped . '">'; + $fullElement[] = '<input type="hidden" name="' . $nullControlNameEscaped . '" value="' . $fallbackValue . '" />'; + $fullElement[] = '<input type="checkbox" name="' . $nullControlNameEscaped . '" id="' . $nullControlNameEscaped . '" value="1"' . $checked . $disabled . ' />'; $fullElement[] = $overrideLabel; $fullElement[] = '</label>'; $fullElement[] = '</div>'; diff --git a/typo3/sysext/backend/Classes/Form/Element/TextElement.php b/typo3/sysext/backend/Classes/Form/Element/TextElement.php index 8ddf64f71689..e5ea01309842 100644 --- a/typo3/sysext/backend/Classes/Form/Element/TextElement.php +++ b/typo3/sysext/backend/Classes/Form/Element/TextElement.php @@ -77,7 +77,7 @@ class TextElement extends AbstractFormElement $evalList = GeneralUtility::trimExplode(',', $config['eval'], true); $cols = MathUtility::forceIntegerInRange($config['cols'] ?: $this->defaultInputWidth, $this->minimumInputWidth, $this->maxInputWidth); $width = $this->formMaxWidth($cols); - $nullControlNameAttribute = ' name="' . htmlspecialchars('control[active][' . $table . '][' . $row['uid'] . '][' . $fieldName . ']') . '"'; + $nullControlNameEscaped = htmlspecialchars('control[active][' . $table . '][' . $row['uid'] . '][' . $fieldName . ']'); // Setting number of rows $rows = MathUtility::forceIntegerInRange($config['rows'] ?: 5, 1, 20); @@ -226,9 +226,9 @@ class TextElement extends AbstractFormElement $fullElement = []; $fullElement[] = '<div class="t3-form-field-disable"></div>'; $fullElement[] = '<div class="checkbox t3-form-field-eval-null-checkbox">'; - $fullElement[] = '<label>'; - $fullElement[] = '<input type="hidden"' . $nullControlNameAttribute . ' value="0" />'; - $fullElement[] = '<input type="checkbox"' . $nullControlNameAttribute . ' value="1"' . $checked . ' />'; + $fullElement[] = '<label for="' . $nullControlNameEscaped . '">'; + $fullElement[] = '<input type="hidden" name="' . $nullControlNameEscaped . '" value="0" />'; + $fullElement[] = '<input type="checkbox" name="' . $nullControlNameEscaped . '" id="' . $nullControlNameEscaped . '" value="1"' . $checked . ' />'; $fullElement[] = $languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.nullCheckbox'); $fullElement[] = '</label>'; $fullElement[] = '</div>'; @@ -262,9 +262,9 @@ class TextElement extends AbstractFormElement } $fullElement = []; $fullElement[] = '<div class="checkbox t3js-form-field-eval-null-placeholder-checkbox">'; - $fullElement[] = '<label>'; - $fullElement[] = '<input type="hidden"' . $nullControlNameAttribute . ' value="' . $fallbackValue . '" />'; - $fullElement[] = '<input type="checkbox"' . $nullControlNameAttribute . ' value="1"' . $checked . $disabled . ' />'; + $fullElement[] = '<label for="' . $nullControlNameEscaped . '">'; + $fullElement[] = '<input type="hidden" name="' . $nullControlNameEscaped . '" value="' . $fallbackValue . '" />'; + $fullElement[] = '<input type="checkbox" name="' . $nullControlNameEscaped . '" id="' . $nullControlNameEscaped . '" value="1"' . $checked . $disabled . ' />'; $fullElement[] = $overrideLabel; $fullElement[] = '</label>'; $fullElement[] = '</div>'; -- GitLab