Skip to content

Commit 696d3b6

Browse files
authored
[4.0] Make note field hideable (#35017)
1 parent b1b445e commit 696d3b6

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

libraries/src/Form/Field/NoteField.php

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
\defined('JPATH_PLATFORM') or die;
1212

1313
use Joomla\CMS\Form\FormField;
14+
use Joomla\CMS\HTML\HTMLHelper;
1415
use Joomla\CMS\Language\Text;
1516

1617
/**
@@ -60,22 +61,28 @@ protected function getLabel()
6061
return '';
6162
}
6263

63-
$title = $this->element['label'] ? (string) $this->element['label'] : ($this->element['title'] ? (string) $this->element['title'] : '');
64-
$heading = $this->element['heading'] ? (string) $this->element['heading'] : 'h4';
65-
$description = (string) $this->element['description'];
66-
$class = !empty($this->class) ? ' class="' . $this->class . '"' : '';
67-
$close = (string) $this->element['close'];
64+
$html = [];
65+
$class = [];
6866

69-
$html = array();
67+
if (!empty($this->class))
68+
{
69+
$class[] = $this->class;
70+
}
7071

71-
if ($close)
72+
if ($close = (string) $this->element['close'])
7273
{
73-
$close = $close === 'true' ? 'alert' : $close;
74-
$html[] = '<button type="button" class="btn-close" data-dismiss="' . $close . '">&times;</button>';
74+
HTMLHelper::_('bootstrap.alert');
75+
$close = $close === 'true' ? 'alert' : $close;
76+
$html[] = '<button type="button" class="btn-close" data-bs-dismiss="' . $close . '"></button>';
77+
$class[] = 'alert-dismissible show';
7578
}
7679

77-
$html[] = !empty($title) ? '<' . $heading . '>' . Text::_($title) . '</' . $heading . '>' : '';
78-
$html[] = !empty($description) ? Text::_($description) : '';
80+
$class = $class ? ' class="' . implode(' ', $class) . '"' : '';
81+
$title = $this->element['label'] ? (string) $this->element['label'] : ($this->element['title'] ? (string) $this->element['title'] : '');
82+
$heading = $this->element['heading'] ? (string) $this->element['heading'] : 'h4';
83+
$description = (string) $this->element['description'];
84+
$html[] = !empty($title) ? '<' . $heading . '>' . Text::_($title) . '</' . $heading . '>' : '';
85+
$html[] = !empty($description) ? Text::_($description) : '';
7986

8087
return '</div><div ' . $class . '>' . implode('', $html);
8188
}

0 commit comments

Comments
 (0)