[BUGFIX] EXT:form - Fix CHECKBOXGROUP and RADIOGROUP in form wizard 10/45410/6
authorAndreas Häfner <andreas.haefner@tritum.de>
Tue, 22 Dec 2015 16:23:05 +0000 (17:23 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Fri, 4 Mar 2016 16:02:43 +0000 (17:02 +0100)
Fixes a JS error, which appeared when adding a CHECKBOXGROUP or
RADIOGROUP within the form wizard.

Furthermore it applies "text" instead of "data" which was already
changed for TEXTAREA and OPTION elements (as discussed in #69369).

Resolves: #72316
Releases: master, 7.6
Change-Id: I758ad36530ea29ca5469e510367fdedde34c5bd6
Reviewed-on: https://review.typo3.org/45410
Reviewed-by: Bjoern Jacob <bjoern.jacob@tritum.de>
Tested-by: Bjoern Jacob <bjoern.jacob@tritum.de>
Tested-by: Gianluigi Martino <gmartino27@gmail.com>
Tested-by: Florian Mast <flo.mast@web.de>
Reviewed-by: Florian Mast <flo.mast@web.de>
Reviewed-by: Eugen Lang <laeu1011+gerrit@gmail.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/form/Classes/Domain/Model/Json/CheckboxGroupJsonElement.php
typo3/sysext/form/Classes/Domain/Model/Json/RadioGroupJsonElement.php
typo3/sysext/form/Resources/Public/JavaScript/Wizard/Elements/Predefined/CheckboxGroup.js
typo3/sysext/form/Resources/Public/JavaScript/Wizard/Elements/Predefined/RadioGroup.js
typo3/sysext/form/Resources/Public/JavaScript/Wizard/Viewport/Left/Options/Forms/Options.js

index 350a406..21dd5b7 100644 (file)
@@ -90,8 +90,12 @@ class CheckboxGroupJsonElement extends \TYPO3\CMS\Form\Domain\Model\Json\Fieldse
                             $childElementArguments['attributes']['selected'] = 'selected';
                             unset($childElementArguments['checked']);
                         }
+                        if (isset($childElementArguments['value'])) {
+                            $childElementArguments['attributes']['value'] = $childElementArguments['value'];
+                            unset($childElementArguments['value']);
+                        }
                         if (isset($childElementArguments['label.'])) {
-                            $childElementArguments['data'] = $childElementArguments['label.']['value'];
+                            $childElementArguments['text'] = $childElementArguments['label.']['value'];
                             unset($childElementArguments['label.']);
                         }
                         $this->configuration['options'][] = $childElementArguments;
index 86df8d8..90e18c5 100644 (file)
@@ -90,8 +90,12 @@ class RadioGroupJsonElement extends \TYPO3\CMS\Form\Domain\Model\Json\FieldsetJs
                             $childElementArguments['attributes']['selected'] = 'selected';
                             unset($childElementArguments['checked']);
                         }
+                        if (isset($childElementArguments['value'])) {
+                            $childElementArguments['attributes']['value'] = $childElementArguments['value'];
+                            unset($childElementArguments['value']);
+                        }
                         if (isset($childElementArguments['label.'])) {
-                            $childElementArguments['data'] = $childElementArguments['label.']['value'];
+                            $childElementArguments['text'] = $childElementArguments['label.']['value'];
                             unset($childElementArguments['label.']);
                         }
                         $this->configuration['options'][] = $childElementArguments;
index eb00a20..563515f 100644 (file)
@@ -72,11 +72,20 @@ TYPO3.Form.Wizard.Elements.Predefined.CheckboxGroup = Ext.extend(TYPO3.Form.Wiza
                                },
                                options: [
                                        {
-                                               data: TYPO3.l10n.localize('elements_option_1')
-                                       }, {
-                                               data: TYPO3.l10n.localize('elements_option_2')
-                                       }, {
-                                               data: TYPO3.l10n.localize('elements_option_3')
+                                               text: TYPO3.l10n.localize('elements_option_1'),
+                                               attributes: {
+                                                       value: TYPO3.l10n.localize('elements_value_1')
+                                               }
+                                       },{
+                                               text: TYPO3.l10n.localize('elements_option_2'),
+                                               attributes: {
+                                                       value: TYPO3.l10n.localize('elements_value_2')
+                                               }
+                                       },{
+                                               text: TYPO3.l10n.localize('elements_option_3'),
+                                               attributes: {
+                                                       value: TYPO3.l10n.localize('elements_value_3')
+                                               }
                                        }
                                ],
                                various: {
@@ -118,9 +127,11 @@ TYPO3.Form.Wizard.Elements.Predefined.CheckboxGroup = Ext.extend(TYPO3.Form.Wiza
                                });
                                var checkboxConfiguration = {
                                        label: {
-                                               value: option.data
+                                               value: option.text
                                        },
-                                       attributes: {}
+                                       attributes: {
+                                               value: option.attributes.value
+                                       }
                                };
                                if (
                                        option.attributes &&
index feb4fd0..2db6d5b 100644 (file)
@@ -72,11 +72,20 @@ TYPO3.Form.Wizard.Elements.Predefined.RadioGroup = Ext.extend(TYPO3.Form.Wizard.
                                },
                                options: [
                                        {
-                                               data: TYPO3.l10n.localize('elements_option_1')
-                                       }, {
-                                               data: TYPO3.l10n.localize('elements_option_2')
-                                       }, {
-                                               data: TYPO3.l10n.localize('elements_option_3')
+                                               text: TYPO3.l10n.localize('elements_option_1'),
+                                               attributes: {
+                                                       value: TYPO3.l10n.localize('elements_value_1')
+                                               }
+                                       },{
+                                               text: TYPO3.l10n.localize('elements_option_2'),
+                                               attributes: {
+                                                       value: TYPO3.l10n.localize('elements_value_2')
+                                               }
+                                       },{
+                                               text: TYPO3.l10n.localize('elements_option_3'),
+                                               attributes: {
+                                                       value: TYPO3.l10n.localize('elements_value_3')
+                                               }
                                        }
                                ],
                                various: {
@@ -118,9 +127,11 @@ TYPO3.Form.Wizard.Elements.Predefined.RadioGroup = Ext.extend(TYPO3.Form.Wizard.
                                });
                                var radioConfiguration = {
                                        label: {
-                                               value: option.data
+                                               value: option.text
                                        },
-                                       attributes: {}
+                                       attributes: {
+                                               value: option.attributes.value
+                                       }
                                };
                                if (
                                        option.attributes &&
index cc9ea62..a4772e7 100644 (file)
@@ -65,7 +65,7 @@ TYPO3.Form.Wizard.Viewport.Left.Options.Forms.Options = Ext.extend(Ext.grid.Edit
                                type: 'bool'
                        }, {
                                name: 'value',
-                               mapping: 'attributes.value',
+                               convert: this.convertValue,
                                type: 'string'
                        }
                ]);
@@ -227,7 +227,23 @@ TYPO3.Form.Wizard.Viewport.Left.Options.Forms.Options = Ext.extend(Ext.grid.Edit
                        }
                }
                return false;
+       },
+
+       /**
+        * Remap value from different locations
+        *
+        * @param v
+        * @param record
+        * @returns {string}
+        */
+       convertValue: function (v, record) {
+               if (record.attributes && record.attributes.value) {
+                       return record.attributes.value;
+               } else if (record.data) {
+                       return record.data;
+               }
+               return '';
        }
 });
 
-Ext.reg('typo3-form-wizard-viewport-left-options-forms-options', TYPO3.Form.Wizard.Viewport.Left.Options.Forms.Options);
\ No newline at end of file
+Ext.reg('typo3-form-wizard-viewport-left-options-forms-options', TYPO3.Form.Wizard.Viewport.Left.Options.Forms.Options);