diff --git a/layouts/joomla/form/renderlabel.php b/layouts/joomla/form/renderlabel.php index 011c18e3547bf..3f633a8266854 100644 --- a/layouts/joomla/form/renderlabel.php +++ b/layouts/joomla/form/renderlabel.php @@ -22,17 +22,23 @@ */ $classes = array_filter((array) $classes); -$id = $for . '-lbl'; + +// $labelId is the id of the label element itself (always $for . '-lbl'). +// NOTE: Do not use $id here — $id in $displayData is the input control's id, +// not the label's own id. Using $id ?? ... would silently reuse the input id +// because extract() already sets $id to a non-null value for every field. +$labelId = $for ? $for . '-lbl' : null; +$tag = empty($for) ? 'span' : 'label'; if ($required) { $classes[] = 'required'; } ?> - +> diff --git a/libraries/src/Form/Field/CaptchaField.php b/libraries/src/Form/Field/CaptchaField.php index b24514b312372..598f61aa7a8cc 100644 --- a/libraries/src/Form/Field/CaptchaField.php +++ b/libraries/src/Form/Field/CaptchaField.php @@ -165,6 +165,36 @@ public function setup(\SimpleXMLElement $element, $value, $group = null) return $result; } + /** + * Method to get the field label markup. + * + * Overrides the default to guard against null captcha instances and + * to produce a proper