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
@@ -30,7 +30,7 @@ global $CFG;
require_once('HTML/QuickForm/element.php');
require_once($CFG->dirroot.'/lib/filelib.php');
require_once($CFG->dirroot.'/repository/lib.php');
require_once($CFG->libdir.'/outputcomponents.php');
require_once('templatable_form_element.php');
/**
* Editor element
@@ -45,6 +45,10 @@ require_once($CFG->libdir.'/outputcomponents.php');
* @todo MDL-29426 ajax format conversion
*/
class MoodleQuickForm_editor extends HTML_QuickForm_element implements templatable {
use templatable_form_element {
export_for_template as export_for_template_base;
}
/** @var string html for help button, if empty then no help will icon will be dispalyed. */
public $_helpbutton = '';
@@ -451,11 +455,7 @@ class MoodleQuickForm_editor extends HTML_QuickForm_element implements templatab
}
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);
$context['html'] = $this->toHtml();
return $context;
}