MDL-55417 forms: Clean up form element template patch

Use a trait and a base mustache template for all form elements to reduce code
duplication and increase standardisation.

Part of MDL-55071
This commit is contained in:
Damyon Wiese
2016-09-23 10:53:30 +01:00
committed by Dan Poltawski
parent 91bda4cd45
commit 344321e1ef
54 changed files with 483 additions and 748 deletions
+6 -6
View File
@@ -26,7 +26,7 @@
*/
require_once("HTML/QuickForm/submit.php");
require_once(__DIR__ . '/../outputcomponents.php');
require_once('templatable_form_element.php');
/**
* submit type form element
@@ -39,6 +39,10 @@ require_once(__DIR__ . '/../outputcomponents.php');
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class MoodleQuickForm_submit extends HTML_QuickForm_submit implements templatable {
use templatable_form_element {
export_for_template as export_for_template_base;
}
/**
* constructor
*
@@ -110,11 +114,7 @@ class MoodleQuickForm_submit extends HTML_QuickForm_submit implements templatabl
}
public function export_for_template(renderer_base $output) {
$context = [];
$context['frozen'] = $this->_flagFrozen;
foreach ($this->getAttributes() as $name => $value) {
$context[$name] = $value;
}
$context = $this->export_for_template_base($output);
if ($this->getName() == 'cancel') {
$context['iscancel'] = true;
}