[TASK] EXT:form - add empty option to select elements 18/52018/7
authorRalf Zimmermann <ralf.zimmermann@tritum.de>
Mon, 13 Mar 2017 00:14:06 +0000 (01:14 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Thu, 23 Mar 2017 14:45:26 +0000 (15:45 +0100)
Add configuration for fluid's select VH attribute 'prependOptionLabel'.

Resolves: #80192
Releases: master
Change-Id: Id045fac0d4d65ab4127607ec4ed1384757a0201f
Reviewed-on: https://review.typo3.org/52018
Reviewed-by: Bjoern Jacob <bjoern.jacob@tritum.de>
Tested-by: Bjoern Jacob <bjoern.jacob@tritum.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Mona Muzaffar <mona.muzaffar@gmx.de>
Tested-by: Mona Muzaffar <mona.muzaffar@gmx.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/form/Configuration/Yaml/FormEditorSetup.yaml
typo3/sysext/form/Resources/Private/Frontend/Partials/MultiSelect.html
typo3/sysext/form/Resources/Private/Frontend/Partials/SingleSelect.html
typo3/sysext/form/Resources/Private/Language/Database.xlf

index dab7356..9ea97c7 100644 (file)
@@ -411,6 +411,14 @@ TYPO3:
                 group: select
                 groupSorting: 400
                 iconIdentifier: 't3-form-icon-multi-select'
+                editors:
+                  250:
+                    identifier: 'inactiveOption'
+                    templateName: 'Inspector-TextEditor'
+                    label: 'formEditor.elements.SelectionMixin.editor.inactiveOption.label'
+                    propertyPath: 'properties.prependOptionLabel'
+                    fieldExplanationText: 'formEditor.elements.SelectionMixin.editor.inactiveOption.fieldExplanationText'
+                    doNotSetIfPropertyValueIsEmpty: true
 
             RadioButton:
               formEditor:
@@ -425,6 +433,14 @@ TYPO3:
                 group: select
                 groupSorting: 200
                 iconIdentifier: 't3-form-icon-single-select'
+                editors:
+                  250:
+                    identifier: 'inactiveOption'
+                    templateName: 'Inspector-TextEditor'
+                    label: 'formEditor.elements.SelectionMixin.editor.inactiveOption.label'
+                    propertyPath: 'properties.prependOptionLabel'
+                    fieldExplanationText: 'formEditor.elements.SelectionMixin.editor.inactiveOption.fieldExplanationText'
+                    doNotSetIfPropertyValueIsEmpty: true
 
             ### FORM ELEMENTS: CUSTOM ###
             DatePicker:
index 6bd80ac..0e60910 100644 (file)
@@ -1,15 +1,33 @@
 <html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" xmlns:formvh="http://typo3.org/ns/TYPO3/CMS/Form/ViewHelpers" data-namespace-typo3-fluid="true">
 <formvh:renderRenderable renderable="{element}">
        <f:render partial="Field/Field" arguments="{element: element}" contentAs="elementContent">
-               <f:form.select
-                       property="{element.identifier}"
-                       id="{element.uniqueIdentifier}"
-                       class="{element.properties.elementClassAttribute} form-control"
-                       options="{formvh:translateElementProperty(element: element, property: 'options')}"
-                       multiple="multiple"
-                       errorClass="{element.properties.elementErrorClassAttribute}"
-                       additionalAttributes="{formvh:translateElementProperty(element: element, property: 'fluidAdditionalAttributes')}"
-               />
+               <f:if condition="{element.properties.prependOptionLabel}">
+                       <f:then>
+                               <f:form.select
+                                               property="{element.identifier}"
+                                               id="{element.uniqueIdentifier}"
+                                               class="{element.properties.elementClassAttribute} form-control"
+                                               options="{formvh:translateElementProperty(element: element, property: 'options')}"
+                                               multiple="multiple"
+                                               errorClass="{element.properties.elementErrorClassAttribute}"
+                                               additionalAttributes="{formvh:translateElementProperty(element: element, property: 'fluidAdditionalAttributes')}"
+                                               prependOptionLabel="{formvh:translateElementProperty(element: element, property: 'prependOptionLabel')}"
+                                               prependOptionValue="{formvh:translateElementProperty(element: element, property: 'prependOptionValue')}"
+                               />
+                       </f:then>
+                       <f:else>
+                               <f:form.select
+                                               property="{element.identifier}"
+                                               id="{element.uniqueIdentifier}"
+                                               class="{element.properties.elementClassAttribute} form-control"
+                                               options="{formvh:translateElementProperty(element: element, property: 'options')}"
+                                               multiple="multiple"
+                                               errorClass="{element.properties.elementErrorClassAttribute}"
+                                               additionalAttributes="{formvh:translateElementProperty(element: element, property: 'fluidAdditionalAttributes')}"
+                               />
+                       </f:else>
+               </f:if>
+
        </f:render>
 </formvh:renderRenderable>
 </html>
index b343a7c..73a68ff 100644 (file)
@@ -1,14 +1,30 @@
 <html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" xmlns:formvh="http://typo3.org/ns/TYPO3/CMS/Form/ViewHelpers" data-namespace-typo3-fluid="true">
 <formvh:renderRenderable renderable="{element}">
        <f:render partial="Field/Field" arguments="{element: element}" contentAs="elementContent">
-               <f:form.select
-                       property="{element.identifier}"
-                       id="{element.uniqueIdentifier}"
-                       options="{formvh:translateElementProperty(element: element, property: 'options')}"
-                       class="{element.properties.elementClassAttribute} form-control"
-                       errorClass="{element.properties.elementErrorClassAttribute}"
-                       additionalAttributes="{formvh:translateElementProperty(element: element, property: 'fluidAdditionalAttributes')}"
-               />
+               <f:if condition="{element.properties.prependOptionLabel}">
+                       <f:then>
+                               <f:form.select
+                                               property="{element.identifier}"
+                                               id="{element.uniqueIdentifier}"
+                                               options="{formvh:translateElementProperty(element: element, property: 'options')}"
+                                               class="{element.properties.elementClassAttribute} form-control"
+                                               errorClass="{element.properties.elementErrorClassAttribute}"
+                                               additionalAttributes="{formvh:translateElementProperty(element: element, property: 'fluidAdditionalAttributes')}"
+                                               prependOptionLabel="{formvh:translateElementProperty(element: element, property: 'prependOptionLabel')}"
+                                               prependOptionValue="{formvh:translateElementProperty(element: element, property: 'prependOptionValue')}"
+                               />
+                       </f:then>
+                       <f:else>
+                               <f:form.select
+                                               property="{element.identifier}"
+                                               id="{element.uniqueIdentifier}"
+                                               options="{formvh:translateElementProperty(element: element, property: 'options')}"
+                                               class="{element.properties.elementClassAttribute} form-control"
+                                               errorClass="{element.properties.elementErrorClassAttribute}"
+                                               additionalAttributes="{formvh:translateElementProperty(element: element, property: 'fluidAdditionalAttributes')}"
+                               />
+                       </f:else>
+               </f:if>
        </f:render>
 </formvh:renderRenderable>
 </html>
index a74b7cd..66ad83b 100644 (file)
                 <source>Enter a valid PHP PCRE regular expression here.</source>
             </trans-unit>
 
+            <trans-unit id="formEditor.elements.SelectionMixin.editor.inactiveOption.label" xml:space="preserve">
+                <source>Inactive option</source>
+            </trans-unit>
+            <trans-unit id="formEditor.elements.SelectionMixin.editor.inactiveOption.fieldExplanationText" xml:space="preserve">
+                <source>If set, this label will be shown as first option.</source>
+            </trans-unit>
             <trans-unit id="formEditor.elements.SelectionMixin.editor.options.label" xml:space="preserve">
                 <source>Choices</source>
             </trans-unit>