MDL-80192 forms: implement method to set group element hidden label.

This is consistent with the API used for other form element types,
in order to provide screen-readable text in the fieldset legend while
not necessarily wanting to display said label.

The new class property is automatically exported to the template via
the `templatable_form_element` trait.
This commit is contained in:
Paul Holden
2024-01-12 08:33:45 +00:00
parent 287cfcbe83
commit 3cc4de3368
2 changed files with 16 additions and 0 deletions
+12
View File
@@ -46,6 +46,9 @@ class MoodleQuickForm_group extends HTML_QuickForm_group implements templatable
/** @var string html for help button, if empty then no help */
var $_helpbutton='';
/** @var bool if true label will be hidden. */
protected $_hiddenLabel = false;
/** @var MoodleQuickForm */
protected $_mform = null;
@@ -104,6 +107,15 @@ class MoodleQuickForm_group extends HTML_QuickForm_group implements templatable
}
}
/**
* Sets label to be hidden
*
* @param bool $hiddenLabel sets if label should be hidden
*/
public function setHiddenLabel($hiddenLabel) {
$this->_hiddenLabel = $hiddenLabel;
}
/**
* Sets the grouped elements and hides label
*
+4
View File
@@ -1,6 +1,10 @@
This files describes API changes in core_form libraries and APIs,
information provided here is intended especially for developers.
=== 4.2.6 ===
* New method `setHiddenLabel` added to the group form element type
=== 4.2.4 ===
* The group element has a new method `getAttributesForFormElement` which should be used in conjunction