MDL-56705 forms: Use [] for multiple values
Some "select" based form elements are not inheriting directly from MoodleQuickForm_select - so did not have the adjustment to the form field name that allows multiple values. I moved this fix to the templateable trait so all the form fields get this fix.
This commit is contained in:
@@ -224,10 +224,6 @@ class MoodleQuickForm_select extends HTML_QuickForm_select implements templatabl
|
||||
}
|
||||
$context['options'] = $options;
|
||||
|
||||
if ($this->getAttribute('multiple')) {
|
||||
$context['name'] = $context['name'] . '[]';
|
||||
}
|
||||
|
||||
return $context;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,6 +82,11 @@ trait templatable_form_element {
|
||||
$context['type'] = $this->getType();
|
||||
$context['attributes'] = implode(' ', $otherattributes);
|
||||
|
||||
// Elements with multiple values need array syntax.
|
||||
if ($this->getAttribute('multiple')) {
|
||||
$context['name'] = $context['name'] . '[]';
|
||||
}
|
||||
|
||||
return $context;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user