40 lines
1.3 KiB
PHP
40 lines
1.3 KiB
PHP
<?php
|
|
namespace local_treestudyplan\local\form_elements;
|
|
use MoodleQuickForm_text;
|
|
use MoodleQuickForm;
|
|
|
|
|
|
defined('MOODLE_INTERNAL') || die();
|
|
global $CFG;
|
|
require_once($CFG->libdir . "/form/text.php");
|
|
|
|
|
|
class text_integer extends MoodleQuickForm_text {
|
|
public function toHtml()
|
|
{
|
|
global $PAGE;
|
|
// Add number type attribute
|
|
$this->_attributes['type'] = 'number';
|
|
|
|
$html = parent::toHtml();
|
|
// Add javascript call to handle stuff
|
|
$PAGE->requires->js_call_amd('local_treestudyplan/util/formfields', 'text_integer', ['id' => $this->getAttribute('id')]);
|
|
return $html;
|
|
}
|
|
|
|
public static function Register() {
|
|
global $CFG;
|
|
MoodleQuickForm::registerElementType(
|
|
// The custom element is named `course_competency_rule`.
|
|
// This is the element name used in the `addElement()` function.
|
|
'text_integer',
|
|
|
|
// This is where it's definition is defined.
|
|
// This does not currently support class auto-loading.
|
|
"$CFG->dirroot/local/treestudyplan/classes/local/form_elements/text_integer.php",
|
|
|
|
// The class name of the element.
|
|
'local_treestudyplan\local\form_elements\text_integer'
|
|
);
|
|
}
|
|
} |