diff --git a/libraries/src/Form/FormField.php b/libraries/src/Form/FormField.php index d328421e3bf69..824594aef6816 100644 --- a/libraries/src/Form/FormField.php +++ b/libraries/src/Form/FormField.php @@ -1316,17 +1316,12 @@ public function postProcess($value, $group = null, Registry $input = null) */ protected function getLayoutData() { - // Label preprocess - $label = !empty($this->element['label']) ? (string) $this->element['label'] : null; - $label = $label && $this->translateLabel ? Text::_($label) : $label; - - // Description preprocess + $label = !empty($this->element['label']) ? (string) $this->element['label'] : null; + $label = $label && $this->translateLabel ? Text::_($label) : $label; $description = !empty($this->description) ? $this->description : null; $description = !empty($description) && $this->translateDescription ? Text::_($description) : $description; - - $alt = preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname); - - return [ + $alt = preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname); + $options = [ 'autocomplete' => $this->autocomplete, 'autofocus' => $this->autofocus, 'class' => $this->class, @@ -1356,6 +1351,22 @@ protected function getLayoutData() 'dataAttributes' => $this->dataAttributes, 'parentclass' => $this->parentclass, ]; + + // Enable showOn from nested options + if (!empty((array) $this->element->xpath('option'))) + { + foreach ($this->element->xpath('option') as $option) + { + if ((string) $option['showon']) + { + $options['showonEnabled'] = true; + + break; + } + } + } + + return $options; } /**