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:
Damyon Wiese
2016-11-10 14:57:58 +08:00
parent 258d07d37e
commit e7bda18de6
2 changed files with 5 additions and 4 deletions
-4
View File
@@ -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;
}
}
+5
View File
@@ -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;
}
}