Skip to content
Closed
29 changes: 20 additions & 9 deletions libraries/src/Form/FormField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}

/**
Expand Down