diff --git a/lang/en/form.php b/lang/en/form.php index 6c6861ba3cb..440997cb63e 100644 --- a/lang/en/form.php +++ b/lang/en/form.php @@ -50,6 +50,7 @@ $string['filetypesnotall'] = 'It is not allowed to select \'All file types\' her $string['filetypesnotallowed'] = 'These file types are not allowed here: {$a}'; $string['filetypesothers'] = 'Other files'; $string['filetypesunknown'] = 'Unknown file types: {$a}'; +$string['formactions'] = 'Form actions'; $string['general'] = 'General'; $string['hideadvanced'] = 'Hide advanced'; $string['hour'] = 'Hour'; diff --git a/lib/form/group.php b/lib/form/group.php index 533c7f857bf..aa5132b648c 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; @@ -113,6 +116,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 a9cfc380048..9b945b74cd3 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.3.3 === + +* New method `setHiddenLabel` added to the group form element type + === 4.3.1 === * The group element has a new method `getAttributesForFormElement` which should be used in conjunction diff --git a/reportbuilder/classes/form/condition.php b/reportbuilder/classes/form/condition.php index 7d6f8b5dd45..224cc529aff 100644 --- a/reportbuilder/classes/form/condition.php +++ b/reportbuilder/classes/form/condition.php @@ -146,9 +146,10 @@ class condition extends dynamic_form { $buttons = []; $buttons[] = $mform->createElement('submit', 'submitbutton', get_string('apply', 'core_reportbuilder')); $buttons[] = $mform->createElement('submit', 'resetconditions', get_string('resetall', 'core_reportbuilder'), - null, null, ['customclassoverride' => 'btn-link']); + null, null, ['customclassoverride' => 'btn-link ml-1']); - $mform->addGroup($buttons, 'buttonar', '', [' '], false); + $mform->addGroup($buttons, 'buttonar', get_string('formactions', 'core_form'), '', false) + ->setHiddenLabel(true); $mform->closeHeaderBefore('buttonar'); $mform->disable_form_change_checker(); diff --git a/reportbuilder/classes/form/filter.php b/reportbuilder/classes/form/filter.php index 99c8bf66850..58860926e9d 100644 --- a/reportbuilder/classes/form/filter.php +++ b/reportbuilder/classes/form/filter.php @@ -149,9 +149,10 @@ class filter extends dynamic_form { $buttons = []; $buttons[] = $mform->createElement('submit', 'submitbutton', get_string('apply', 'core_reportbuilder')); $buttons[] = $mform->createElement('submit', 'resetfilters', get_string('resetall', 'core_reportbuilder'), - null, null, ['customclassoverride' => 'btn-link']); + null, null, ['customclassoverride' => 'btn-link ml-1']); - $mform->addGroup($buttons, 'buttonar', '', [' '], false); + $mform->addGroup($buttons, 'buttonar', get_string('formactions', 'core_form'), '', false) + ->setHiddenLabel(true); $mform->closeHeaderBefore('buttonar'); $mform->disable_form_change_checker(); diff --git a/reportbuilder/classes/local/filters/date.php b/reportbuilder/classes/local/filters/date.php index 5c9a8b6a38d..aabd3987095 100644 --- a/reportbuilder/classes/local/filters/date.php +++ b/reportbuilder/classes/local/filters/date.php @@ -143,7 +143,8 @@ class date extends base { $mform->hideIf("{$this->name}_unit", "{$this->name}_operator", 'in', $typesnounit); // Add operator/value/unit group. - $mform->addGroup($elements, "{$this->name}_group", '', '', false); + $mform->addGroup($elements, "{$this->name}_group", $this->get_header(), '', false) + ->setHiddenLabel(true); // Date selectors for range operator. $mform->addElement('date_selector', "{$this->name}_from", get_string('filterdatefrom', 'core_reportbuilder'), diff --git a/reportbuilder/classes/local/filters/duration.php b/reportbuilder/classes/local/filters/duration.php index 0b65a3360f6..543be59eda5 100644 --- a/reportbuilder/classes/local/filters/duration.php +++ b/reportbuilder/classes/local/filters/duration.php @@ -96,7 +96,8 @@ class duration extends base { $mform->setDefault("{$this->name}_unit", 1); $mform->hideIf("{$this->name}_unit", "{$this->name}_operator", 'eq', self::DURATION_ANY); - $mform->addGroup($elements, "{$this->name}_group", '', '', false); + $mform->addGroup($elements, "{$this->name}_group", $this->get_header(), '', false) + ->setHiddenLabel(true); } /** diff --git a/reportbuilder/classes/local/filters/number.php b/reportbuilder/classes/local/filters/number.php index f884b659915..8ef02a45f49 100644 --- a/reportbuilder/classes/local/filters/number.php +++ b/reportbuilder/classes/local/filters/number.php @@ -93,16 +93,16 @@ class number extends base { get_string('filterfieldvalue', 'core_reportbuilder', $this->get_header()), ['size' => 3]); $mform->setType($this->name . '_value1', PARAM_INT); $mform->setDefault($this->name . '_value1', 0); + $mform->hideIf($this->name . '_value1', $this->name . '_operator', 'in', + [self::ANY_VALUE, self::IS_NOT_EMPTY, self::IS_EMPTY]); $objs['text2'] = $mform->createElement('text', $this->name . '_value2', get_string('to'), ['size' => 3]); $mform->setType($this->name . '_value2', PARAM_INT); $mform->setDefault($this->name . '_value2', 0); - - $mform->addElement('group', $this->name . '_grp', '', $objs, '', false); - - $mform->hideIf($this->name . '_value1', $this->name . '_operator', 'in', - [self::ANY_VALUE, self::IS_NOT_EMPTY, self::IS_EMPTY]); $mform->hideIf($this->name . '_value2', $this->name . '_operator', 'noteq', self::RANGE); + + $mform->addGroup($objs, $this->name . '_grp', $this->get_header(), '', false) + ->setHiddenLabel(true); } /** diff --git a/reportbuilder/classes/local/filters/select.php b/reportbuilder/classes/local/filters/select.php index f46aaed3656..5c3a0ea5389 100644 --- a/reportbuilder/classes/local/filters/select.php +++ b/reportbuilder/classes/local/filters/select.php @@ -84,7 +84,8 @@ class select extends base { $elements['value'] = $mform->createElement($element, $this->name . '_value', get_string('filterfieldvalue', 'core_reportbuilder', $this->get_header()), $options); - $mform->addElement('group', $this->name . '_group', '', $elements, '', false); + $mform->addGroup($elements, $this->name . '_group', $this->get_header(), '', false) + ->setHiddenLabel(true); $mform->hideIf($this->name . '_value', $this->name . '_operator', 'eq', self::ANY_VALUE); } diff --git a/reportbuilder/classes/local/filters/text.php b/reportbuilder/classes/local/filters/text.php index 791a92598dd..caa41270d33 100644 --- a/reportbuilder/classes/local/filters/text.php +++ b/reportbuilder/classes/local/filters/text.php @@ -92,7 +92,8 @@ class text extends base { $elements['value'] = $mform->createElement('text', $this->name . '_value', get_string('filterfieldvalue', 'core_reportbuilder', $this->get_header())); - $mform->addElement('group', $this->name . '_group', '', $elements, '', false); + $mform->addGroup($elements, $this->name . '_group', $this->get_header(), '', false) + ->setHiddenLabel(true); $mform->setType($this->name . '_value', PARAM_RAW); $mform->hideIf($this->name . '_value', $this->name . '_operator', 'eq', self::ANY_VALUE);