mirror of
https://github.com/moodle/moodle.git
synced 2025-08-09 19:06:41 +02:00
MDL-78527 forms: New parentclass attribute to wrapper element only
This commit is contained in:
parent
b4c6ed3650
commit
0122c2c3e7
5 changed files with 22 additions and 5 deletions
|
@ -59,9 +59,18 @@ class MoodleQuickForm_group extends HTML_QuickForm_group implements templatable
|
||||||
* @param array $elements (optional) array of HTML_QuickForm_element elements to group
|
* @param array $elements (optional) array of HTML_QuickForm_element elements to group
|
||||||
* @param string $separator (optional) string to seperate elements.
|
* @param string $separator (optional) string to seperate elements.
|
||||||
* @param string $appendName (optional) string to appened to grouped elements.
|
* @param string $appendName (optional) string to appened to grouped elements.
|
||||||
|
* @param mixed $attributes (optional) Either a typical HTML attribute string
|
||||||
|
* or an associative array
|
||||||
*/
|
*/
|
||||||
public function __construct($elementName=null, $elementLabel=null, $elements=null, $separator=null, $appendName = true) {
|
public function __construct(
|
||||||
parent::__construct($elementName, $elementLabel, $elements, $separator, $appendName);
|
$elementName = null,
|
||||||
|
$elementLabel = null,
|
||||||
|
$elements = null,
|
||||||
|
$separator = null,
|
||||||
|
$appendName = true,
|
||||||
|
$attributes = null
|
||||||
|
) {
|
||||||
|
parent::__construct($elementName, $elementLabel, $elements, $separator, $appendName, $attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -66,6 +66,7 @@ trait templatable_form_element {
|
||||||
$context[strtolower($propname)] = isset($this->$classpropname) ? $this->$classpropname : false;
|
$context[strtolower($propname)] = isset($this->$classpropname) ? $this->$classpropname : false;
|
||||||
}
|
}
|
||||||
$extraclasses = $this->getAttribute('class');
|
$extraclasses = $this->getAttribute('class');
|
||||||
|
$parentonlyclasses = $this->getAttribute('parentclass');
|
||||||
|
|
||||||
// Special wierd named property.
|
// Special wierd named property.
|
||||||
$context['frozen'] = !empty($this->_flagFrozen);
|
$context['frozen'] = !empty($this->_flagFrozen);
|
||||||
|
@ -74,11 +75,12 @@ trait templatable_form_element {
|
||||||
// Other attributes.
|
// Other attributes.
|
||||||
$otherattributes = [];
|
$otherattributes = [];
|
||||||
foreach ($this->getAttributes() as $attr => $value) {
|
foreach ($this->getAttributes() as $attr => $value) {
|
||||||
if (!in_array($attr, $standardattributes) && $attr != 'class' && !is_object($value)) {
|
if (!in_array($attr, $standardattributes) && $attr != 'class' && $attr != 'parentclass' && !is_object($value)) {
|
||||||
$otherattributes[] = $attr . '="' . s($value) . '"';
|
$otherattributes[] = $attr . '="' . s($value) . '"';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$context['extraclasses'] = $extraclasses;
|
$context['extraclasses'] = $extraclasses;
|
||||||
|
$context['parentclasses'] = $parentonlyclasses;
|
||||||
$context['type'] = $this->getType();
|
$context['type'] = $this->getType();
|
||||||
$context['attributes'] = implode(' ', $otherattributes);
|
$context['attributes'] = implode(' ', $otherattributes);
|
||||||
$context['emptylabel'] = ($this->getLabel() === '');
|
$context['emptylabel'] = ($this->getLabel() === '');
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
<div id="{{element.wrapperid}}" class="form-group row {{#error}}has-danger{{/error}} fitem {{#element.emptylabel}}femptylabel{{/element.emptylabel}} {{#advanced}}advanced{{/advanced}} {{{element.extraclasses}}}" {{#element.groupname}}data-groupname="{{.}}"{{/element.groupname}}>
|
<div id="{{element.wrapperid}}" class="form-group row {{#error}}has-danger{{/error}} fitem {{#element.emptylabel}}femptylabel{{/element.emptylabel}} {{#advanced}}advanced{{/advanced}} {{{element.extraclasses}}} {{{element.parentclasses}}}" {{#element.groupname}}data-groupname="{{.}}"{{/element.groupname}}>
|
||||||
<div class="col-md-3 col-form-label d-flex pb-0 pr-md-0">
|
<div class="col-md-3 col-form-label d-flex pb-0 pr-md-0">
|
||||||
{{# label}}{{$ label }}
|
{{# label}}{{$ label }}
|
||||||
{{^element.staticlabel}}
|
{{^element.staticlabel}}
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
This files describes API changes in core_form libraries and APIs,
|
This files describes API changes in core_form libraries and APIs,
|
||||||
information provided here is intended especially for developers.
|
information provided here is intended especially for developers.
|
||||||
|
|
||||||
|
=== 4.3 ===
|
||||||
|
|
||||||
|
* Added a new parameter to allow Groups to add attributes.
|
||||||
|
|
||||||
=== 4.2 ===
|
=== 4.2 ===
|
||||||
|
|
||||||
* The moodle-form-passwordunmask module has been removed. It was deprecated in Moodle 3.2.
|
* The moodle-form-passwordunmask module has been removed. It was deprecated in Moodle 3.2.
|
||||||
|
|
|
@ -3370,7 +3370,9 @@ class MoodleQuickForm_Renderer extends HTML_QuickForm_Renderer_Tableless{
|
||||||
$groupid = 'fgroup_' . $group->getAttribute('id');
|
$groupid = 'fgroup_' . $group->getAttribute('id');
|
||||||
|
|
||||||
// Update the ID.
|
// Update the ID.
|
||||||
$group->updateAttributes(array('id' => $groupid));
|
$attributes = $group->getAttributes();
|
||||||
|
$attributes['id'] = $groupid;
|
||||||
|
$group->updateAttributes($attributes);
|
||||||
$advanced = isset($this->_advancedElements[$group->getName()]);
|
$advanced = isset($this->_advancedElements[$group->getName()]);
|
||||||
|
|
||||||
$html = $OUTPUT->mform_element($group, $required, $advanced, $error, false);
|
$html = $OUTPUT->mform_element($group, $required, $advanced, $error, false);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue