mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
MDL-65069 core_form: Expose the form's submit's class attribute
Exposed the submit button's class attribute so it can be overriden by custom classes provided by the programmer.
This commit is contained in:
parent
97babbf7d7
commit
e455d6f483
@ -48,6 +48,13 @@ class MoodleQuickForm_submit extends HTML_QuickForm_submit implements templatabl
|
||||
*/
|
||||
protected $primary;
|
||||
|
||||
/**
|
||||
* Any class apart from 'btn' would be override with this content
|
||||
*
|
||||
* @var string $customclassoverride Custom class override for the input element
|
||||
*/
|
||||
protected $customclassoverride;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
@ -65,6 +72,12 @@ class MoodleQuickForm_submit extends HTML_QuickForm_submit implements templatabl
|
||||
} else {
|
||||
$this->primary = $primary;
|
||||
}
|
||||
|
||||
$class = $this->getAttribute('customclassoverride');
|
||||
if ($class) {
|
||||
$this->removeAttribute('customclassoverride');
|
||||
$this->customclassoverride = $class;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -131,6 +144,10 @@ class MoodleQuickForm_submit extends HTML_QuickForm_submit implements templatabl
|
||||
if (!$this->primary) {
|
||||
$context['secondary'] = true;
|
||||
}
|
||||
|
||||
if ($this->customclassoverride) {
|
||||
$context['customclass'] = $this->customclassoverride;
|
||||
}
|
||||
return $context;
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,12 @@
|
||||
{{^element.frozen}}
|
||||
<input type="submit"
|
||||
class="btn
|
||||
{{^element.secondary}}btn-primary{{/element.secondary}}
|
||||
{{#element.secondary}}btn-secondary{{/element.secondary}}
|
||||
{{#error}} btn-danger {{/error}}"
|
||||
{{^element.customclass}}
|
||||
{{^element.secondary}}btn-primary{{/element.secondary}}
|
||||
{{#element.secondary}}btn-secondary{{/element.secondary}}
|
||||
{{/element.customclass}}
|
||||
{{#error}} btn-danger {{/error}}
|
||||
{{#element.customclass}}{{element.customclass}}{{/element.customclass}}"
|
||||
name="{{element.name}}"
|
||||
id="{{element.id}}"
|
||||
value="{{element.value}}"
|
||||
|
@ -3,9 +3,13 @@
|
||||
{{^element.frozen}}
|
||||
<input type="submit"
|
||||
class="btn
|
||||
{{^element.secondary}}btn-primary{{/element.secondary}}
|
||||
{{#element.secondary}}btn-secondary{{/element.secondary}}
|
||||
{{#error}} btn-danger {{/error}}"
|
||||
{{^element.customclass}}
|
||||
{{^element.secondary}}btn-primary{{/element.secondary}}
|
||||
{{#element.secondary}}btn-secondary{{/element.secondary}}
|
||||
{{/element.customclass}}
|
||||
{{#error}} btn-danger {{/error}}
|
||||
{{element.extraclasses}}
|
||||
{{#element.customclass}}{{element.customclass}}{{/element.customclass}}"
|
||||
name="{{element.name}}"
|
||||
id="{{element.id}}"
|
||||
{{#error}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user