Merge branch 'MDL-59740_master' of git://github.com/markn86/moodle

This commit is contained in:
Jun Pataleta 2017-08-14 13:48:01 +08:00
commit 28368da794

View File

@ -43,15 +43,28 @@ class MoodleQuickForm_submit extends HTML_QuickForm_submit implements templatabl
export_for_template as export_for_template_base;
}
/**
* @var bool $primary Is this button a primary button?
*/
protected $primary;
/**
* constructor
*
* @param string $elementName (optional) name of the field
* @param string $value (optional) field label
* @param string $attributes (optional) Either a typical HTML attribute string or an associative array
* @param bool|null $primary Is this button a primary button?
*/
public function __construct($elementName=null, $value=null, $attributes=null) {
public function __construct($elementName=null, $value=null, $attributes=null, $primary = null) {
parent::__construct($elementName, $value, $attributes);
// Fallback to legacy behaviour if no value specified.
if (is_null($primary)) {
$this->primary = $this->getName() != 'cancel';
} else {
$this->primary = $primary;
}
}
/**
@ -59,9 +72,9 @@ class MoodleQuickForm_submit extends HTML_QuickForm_submit implements templatabl
*
* @deprecated since Moodle 3.1
*/
public function MoodleQuickForm_submit($elementName=null, $value=null, $attributes=null) {
public function MoodleQuickForm_submit($elementName=null, $value=null, $attributes=null, $primary = null) {
debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER);
self::__construct($elementName, $value, $attributes);
self::__construct($elementName, $value, $attributes, $primary);
}
/**
@ -115,7 +128,7 @@ class MoodleQuickForm_submit extends HTML_QuickForm_submit implements templatabl
public function export_for_template(renderer_base $output) {
$context = $this->export_for_template_base($output);
if ($this->getName() == 'cancel') {
if (!$this->primary) {
$context['secondary'] = true;
}
return $context;