#52 Fixed appearance of colour picker in Boost

This commit is contained in:
Mark Nelson 2016-12-12 20:05:44 +08:00
parent f3f9fef1a4
commit 6fb3230e54

View file

@ -16,7 +16,8 @@
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.'); defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
require_once("HTML/QuickForm/text.php"); require_once($CFG->dirroot . '/lib/form/editor.php');
require_once($CFG->dirroot . '/lib/form/templatable_form_element.php');
/** /**
* Form element for handling the colour picker. * Form element for handling the colour picker.
@ -25,7 +26,10 @@ require_once("HTML/QuickForm/text.php");
* @copyright 2013 Mark Nelson <markn@moodle.com> * @copyright 2013 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
class MoodleQuickForm_customcert_colourpicker extends HTML_QuickForm_text { class MoodleQuickForm_customcert_colourpicker extends MoodleQuickForm_editor {
use templatable_form_element {
export_for_template as export_for_template_base;
}
/** /**
* The string for the help icon, if empty then no help icon will be displayed. * The string for the help icon, if empty then no help icon will be displayed.
@ -39,7 +43,7 @@ class MoodleQuickForm_customcert_colourpicker extends HTML_QuickForm_text {
* @param string $elementLabel * @param string $elementLabel
* @param array $attributes * @param array $attributes
*/ */
function __construct($elementName = null, $elementLabel = null, $attributes = null) { public function __construct($elementName = null, $elementLabel = null, $attributes = null) {
parent::__construct($elementName, $elementLabel, $attributes); parent::__construct($elementName, $elementLabel, $attributes);
} }
@ -50,10 +54,24 @@ class MoodleQuickForm_customcert_colourpicker extends HTML_QuickForm_text {
* @param string $elementLabel * @param string $elementLabel
* @param array $attributes * @param array $attributes
*/ */
function MoodleQuickForm_customcert_colourpicker($elementName = null, $elementLabel = null, $attributes = null) { public function MoodleQuickForm_customcert_colourpicker($elementName = null, $elementLabel = null, $attributes = null) {
self::__construct($elementName, $elementLabel, $attributes); self::__construct($elementName, $elementLabel, $attributes);
} }
/**
* Sets the value of the form element
*/
public function setValue($value) {
$this->updateAttributes(array('value' => $value));
}
/**
* Gets the value of the form element
*/
public function getValue() {
return $this->getAttribute('value');
}
/** /**
* Returns the html string to display this element. * Returns the html string to display this element.
* *
@ -82,4 +100,11 @@ class MoodleQuickForm_customcert_colourpicker extends HTML_QuickForm_text {
public function getHelpButton(){ public function getHelpButton(){
return $this->_helpbutton; return $this->_helpbutton;
} }
public function export_for_template(renderer_base $output) {
$context = $this->export_for_template_base($output);
$context['html'] = $this->toHtml();
return $context;
}
} }