Commit f08494eb authored by Francois Gannaz's avatar Francois Gannaz
Browse files

Activity form: mission selector updates name+descr

parent 8a5dd7dc
......@@ -46,19 +46,33 @@ class mod_labnbook_mod_form extends moodleform_mod {
$mform = $this->_form;
$missions = session::load()->getMissions();
$mform->addElement('html', '<script>var missions = ' . json_encode($missions) . ';</script>');
$missionsList = array_map(
function($x) { return "[{$x->code}] {$x->name}"; },
$missions
);
$mform->addElement('header', 'general', "LabNbook");
$mform->addElement('select', 'missionid', get_string('mission', 'mod_labnbook'), array_merge(['' => "-"], $missionsList));
$mform->addElement('header', 'external', "LabNbook");
$mform->addElement(
'select',
'missionid',
get_string('mission', 'mod_labnbook'),
array_merge(['' => "-"], $missionsList),
[
'onchange' => 'javascript: '
. 'document.querySelector("#id_name").value = missions[this.value].name;'
// try to update the Atto text, but Atto is undocumented stuff (wiki pages are all dead)
. 'document.querySelector("#id_introeditor").innerHTML = missions[this.value].description;'
. 'document.querySelector("#id_introeditoreditable").innerHTML = missions[this.value].description;'
]
);
$mform->addRule('missionid', null, 'required', null, 'client');
// Adding the "general" fieldset, where all the common settings are showed.
$mform->addElement('header', 'general', get_string('general', 'form'));
// Adding the standard "name" field.
$mform->addElement('text', 'name', get_string('instancename', 'mod_labnbook'), array('size' => '64'));
$mform->addElement('text', 'name', get_string('instancename', 'mod_labnbook'), ['size' => '64']);
if (!empty($CFG->formatstringstriptags)) {
$mform->setType('name', PARAM_TEXT);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment