From 3cc4de336801d01d672f9eb2d771baa04c8e02f0 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Mon, 20 Nov 2023 17:09:26 +0000 Subject: [PATCH] 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. --- lib/form/group.php | 12 ++++++++++++ lib/form/upgrade.txt | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/lib/form/group.php b/lib/form/group.php index c6417b2d0d2..81094e9512b 100644 --- a/lib/form/group.php +++ b/lib/form/group.php @@ -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 * diff --git a/lib/form/upgrade.txt b/lib/form/upgrade.txt index 923ccfbb328..271fa232aef 100644 --- a/lib/form/upgrade.txt +++ b/lib/form/upgrade.txt @@ -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