Skip to content
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions libraries/src/Form/FormField.php
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,20 @@ public function renderField($options = [])
? ((string) $this->form->getXml()->config->inlinehelp['button'] == 'show' ?: false)
: false;

if ($this->showon) {
// Check if the field has showon in nested option
$hasOptionShowOn = false;

if (!empty((array) $this->element->xpath('option'))) {
foreach ($this->element->xpath('option') as $option) {
if ((string) $option['showon']) {
$hasOptionShowOn = true;

break;
}
}
}

if ($this->showon || $hasOptionShowOn) {
$options['rel'] = ' data-showon=\'' .
json_encode(FormHelper::parseShowOnConditions($this->showon, $this->formControl, $this->group)) . '\'';
$options['showonEnabled'] = true;
Expand Down Expand Up @@ -1252,17 +1265,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 @@ -1292,6 +1300,8 @@ protected function getLayoutData()
'dataAttributes' => $this->dataAttributes,
'parentclass' => $this->parentclass,
];

return $options;
}

/**
Expand Down