[BUGFIX] EXT:form - OPTGROUP cannot be a child element of SELECT 92/43492/3
authorRalf Zimmermann <ralf.zimmermann@tritum.de>
Thu, 24 Sep 2015 21:44:37 +0000 (23:44 +0200)
committerMorton Jonuschat <m.jonuschat@mojocode.de>
Fri, 27 Nov 2015 16:18:50 +0000 (17:18 +0100)
Resolves: #69376
Releases: 6.2
Change-Id: I9e77649203466e37067384f7043e7f1a6ce5fa7e
Reviewed-on: https://review.typo3.org/43492
Reviewed-by: Bjoern Jacob <bjoern.jacob@tritum.de>
Tested-by: Bjoern Jacob <bjoern.jacob@tritum.de>
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
typo3/sysext/form/Classes/Domain/Model/Element/SelectElement.php

index f320b34..8dc33d0 100644 (file)
@@ -52,10 +52,16 @@ class SelectElement extends \TYPO3\CMS\Form\Domain\Model\Element\ContainerElemen
        /**
         * Add child object to this element
         *
-        * @param \TYPO3\CMS\Form\Domain\Model\Element\OptionElement $element The child object
+        * @param \TYPO3\CMS\Form\Domain\Model\Element\OptionElement|\TYPO3\CMS\Form\Domain\Model\Element\OptgroupElement $element The child object
         * @return \TYPO3\CMS\Form\Domain\Model\Element\SelectElement
         */
-       public function addElement(\TYPO3\CMS\Form\Domain\Model\Element\OptionElement $element) {
+       public function addElement(\TYPO3\CMS\Form\Domain\Model\Element\AbstractElement $element) {
+               if (
+                       !($element instanceof \TYPO3\CMS\Form\Domain\Model\Element\OptionElement)
+                       && !($element instanceof \TYPO3\CMS\Form\Domain\Model\Element\OptgroupElement)
+               ) {
+                       throw new \InvalidArgumentException('Element type "' . get_class($element) . '" is not supported.', 1442928537);
+               }
                $element->setParentName($this->getName());
                $this->elements[] = $element;
                return $this;