Skip to content

Commit

Permalink
MDL-56705 forms: Use [] for multiple values
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Damyon Wiese committed Nov 10, 2016
1 parent 258d07d commit e7bda18
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 0 additions & 4 deletions lib/form/select.php
Expand Up @@ -224,10 +224,6 @@ public function export_for_template(renderer_base $output) {
}
$context['options'] = $options;

if ($this->getAttribute('multiple')) {
$context['name'] = $context['name'] . '[]';
}

return $context;
}
}
5 changes: 5 additions & 0 deletions lib/form/templatable_form_element.php
Expand Up @@ -82,6 +82,11 @@ public function export_for_template(renderer_base $output) {
$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;
}
}

0 comments on commit e7bda18

Please sign in to comment.