diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Select.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Select.php index 98e4a3310fac7..e7370a8efaebb 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Select.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Select.php @@ -72,7 +72,8 @@ public function getHtml() $value = $this->getValue(); foreach ($this->_getOptions() as $option) { if (is_array($option['value'])) { - $html .= ''; + $label = isset($option['label']) ? $option['label'] : ''; + $html .= ''; foreach ($option['value'] as $subOption) { $html .= $this->_renderOption($subOption, $value); } diff --git a/lib/internal/Magento/Framework/Data/Form/Element/Select.php b/lib/internal/Magento/Framework/Data/Form/Element/Select.php index e0563c6fa75ad..e951287090df0 100644 --- a/lib/internal/Magento/Framework/Data/Form/Element/Select.php +++ b/lib/internal/Magento/Framework/Data/Form/Element/Select.php @@ -86,8 +86,9 @@ public function getElementHtml() foreach ($values as $key => $option) { if (!is_array($option)) { $html .= $this->_optionToHtml(['value' => $key, 'label' => $option], $value); - } elseif (is_array($option['value'])) { - $html .= '' . "\n"; + } elseif (isset($option['value']) && is_array($option['value'])) { + $label = isset($option['label']) ? $option['label'] : ''; + $html .= '' . "\n"; foreach ($option['value'] as $groupItem) { $html .= $this->_optionToHtml($groupItem, $value); } @@ -119,24 +120,35 @@ public function getElementHtml() */ protected function _optionToHtml($option, $selected) { - if (is_array($option['value'])) { + if (isset($option['value']) && is_array($option['value'])) { + $label = isset($option['label']) ? $option['label'] : ''; $html = '' . "\n"; + foreach ($option['value'] as $groupItem) { $html .= $this->_optionToHtml($groupItem, $selected); } + $html .= '' . "\n"; } else { + $value = isset($option['value']) ? $option['value'] : ''; + $label = isset($option['label']) ? $option['label'] : ''; + $optionId = 'optId' .$this->random->getRandomString(8); - $html = '' . "\n"; + + $html .= '>' . $this->_escape($label) . '' . "\n"; + if (!empty($option['style'])) { $html .= $this->secureRenderer->renderStyleAsTag($option['style'], "#$optionId"); } } + return $html; }