[TASK] fix override label in formengine 18/47618/5
authorKay Strobach <info@kay-strobach.de>
Tue, 12 Apr 2016 09:36:16 +0000 (11:36 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Tue, 12 Apr 2016 15:55:40 +0000 (17:55 +0200)
This patch ensures that we do not display override "" but a more useful
information. Additionally the checkboxes are enabled by default if no
default value available to reduce the effort needed to provide an
element specific value.

Resolves: #75540
Releases: master
Change-Id: I11667232761968c077f02ec18e6802d7e54fcc6f
Reviewed-on: https://review.typo3.org/47618
Reviewed-by: Susanne Moog <typo3@susannemoog.de>
Tested-by: Susanne Moog <typo3@susannemoog.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Classes/Form/Container/SingleFieldContainer.php
typo3/sysext/lang/locallang_core.xlf

index d9a141d..70c1d35 100644 (file)
@@ -253,6 +253,16 @@ class SingleFieldContainer extends AbstractContainer
             $placeholder = empty($parameterArray['fieldConf']['config']['placeholder']) ? '' : $parameterArray['fieldConf']['config']['placeholder'];
             $onChange = 'typo3form.fieldTogglePlaceholder(' . GeneralUtility::quoteJSvalue($parameterArray['itemFormElName']) . ', !this.checked)';
             $checked = $parameterArray['itemFormElValue'] === null ? '' : ' checked="checked"';
+            $disabled = '';
+            $fallbackValue = 0;
+            if (strlen(BackendUtility::getRecordTitlePrep($placeholder, 20)) > 0) {
+                $overrideLabel = sprintf($languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.placeholder.override'), BackendUtility::getRecordTitlePrep($placeholder, 20));
+            } else {
+                $fallbackValue = 1;
+                $checked = ' checked="checked"';
+                $disabled = ' disabled="disabled"';
+                $overrideLabel = sprintf($languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.placeholder.override_not_available'), BackendUtility::getRecordTitlePrep($placeholder, 20));
+            }
 
             $resultArray['additionalJavaScriptPost'][] = 'typo3form.fieldTogglePlaceholder('
                 . GeneralUtility::quoteJSvalue($parameterArray['itemFormElName']) . ', ' . ($checked ? 'false' : 'true') . ');';
@@ -272,9 +282,9 @@ class SingleFieldContainer extends AbstractContainer
             $placeholderWrap[] =    '<div class="t3-form-field-disable"></div>';
             $placeholderWrap[] =    '<div class="checkbox">';
             $placeholderWrap[] =        '<label>';
-            $placeholderWrap[] =            '<input type="hidden"' . $nullControlNameAttribute . ' value="0" />';
-            $placeholderWrap[] =            '<input type="checkbox"' . $nullControlNameAttribute . ' value="1" id="tce-forms-textfield-use-override-' . $fieldName . '-' . $row['uid'] . '" onchange="' . htmlspecialchars($onChange) . '"' . $checked . ' />';
-            $placeholderWrap[] =            sprintf($languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.placeholder.override'), BackendUtility::getRecordTitlePrep($placeholder, 20));
+            $placeholderWrap[] =            '<input type="hidden"' . $nullControlNameAttribute . ' value="' . $fallbackValue . '" />';
+            $placeholderWrap[] =            '<input type="checkbox"' . $nullControlNameAttribute . ' value="1" id="tce-forms-textfield-use-override-' . $fieldName . '-' . $row['uid'] . '" onchange="' . htmlspecialchars($onChange) . '"' . $checked . $disabled . ' />';
+            $placeholderWrap[] =            $overrideLabel;
             $placeholderWrap[] =        '</label>';
             $placeholderWrap[] =    '</div>';
             $placeholderWrap[] =    '<div class="t3js-formengine-placeholder-placeholder">';
index d84dd10..9b49d5e 100644 (file)
@@ -347,7 +347,10 @@ Do you want to continue WITHOUT saving?</source>
                                <source>Uncheck all</source>
                        </trans-unit>
                        <trans-unit id="labels.placeholder.override">
-                               <source>Override "%s"?</source>
+                               <source>Set element specific value (Default: "%s")</source>
+                       </trans-unit>
+                       <trans-unit id="labels.placeholder.override_not_available">
+                               <source>Set element specific value (No default)</source>
                        </trans-unit>
                        <trans-unit id="labels.changeInOrig">
                                <source>Changed in original translation</source>