mirror of
https://github.com/moodle/moodle.git
synced 2025-04-15 05:25:08 +02:00
Merge branch 'wip-MDL-56912-master' of git://github.com/marinaglancy/moodle
This commit is contained in:
commit
64e032b6da
@ -181,6 +181,7 @@ abstract class feedback_item_base {
|
||||
* If it is important which mode the form is in, use $form->get_mode()
|
||||
*
|
||||
* Each item type must add a single form element with the name $item->typ.'_'.$item->id
|
||||
* This element must always be present in form data even if nothing is selected (i.e. use advcheckbox and not checkbox).
|
||||
* To add an element use either:
|
||||
* $form->add_form_element() - adds a single element to the form
|
||||
* $form->add_form_group_element() - adds a group element to the form
|
||||
|
@ -350,11 +350,16 @@ class feedback_item_multichoice extends feedback_item_base {
|
||||
}
|
||||
} else {
|
||||
// Radio.
|
||||
if (!array_key_exists(0, $options)) {
|
||||
// Always add '0' as hidden element, otherwise form submit data may not have this element.
|
||||
$objs[] = ['hidden', $inputname.'[0]'];
|
||||
}
|
||||
foreach ($options as $idx => $label) {
|
||||
$objs[] = ['radio', $inputname.'[0]', '', $label, $idx];
|
||||
}
|
||||
$element = $form->add_form_group_element($item, 'group_'.$inputname, $name, $objs, $separator, $class);
|
||||
$form->set_element_default($inputname.'[0]', $tmpvalue);
|
||||
$form->set_element_type($inputname.'[0]', PARAM_INT);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -305,12 +305,17 @@ class feedback_item_multichoicerated extends feedback_item_base {
|
||||
['select', $inputname, $name, array('' => '') + $options, array('class' => $class)]);
|
||||
} else {
|
||||
$objs = array();
|
||||
if (!array_key_exists(0, $options)) {
|
||||
// Always add '0' as hidden element, otherwise form submit data may not have this element.
|
||||
$objs[] = ['hidden', $inputname];
|
||||
}
|
||||
foreach ($options as $idx => $label) {
|
||||
$objs[] = ['radio', $inputname, '', $label, $idx];
|
||||
}
|
||||
$separator = $info->horizontal ? ' ' : '<br>';
|
||||
$class .= ' multichoicerated-' . ($info->horizontal ? 'horizontal' : 'vertical');
|
||||
$el = $form->add_form_group_element($item, 'group_'.$inputname, $name, $objs, $separator, $class);
|
||||
$form->set_element_type($inputname, PARAM_INT);
|
||||
|
||||
// Set previously input values.
|
||||
$form->set_element_default($inputname, $form->get_item_value($item));
|
||||
|
Loading…
x
Reference in New Issue
Block a user