Skip to content
Snippets Groups Projects
Commit 6e57b2a6 authored by Andreas Gohr's avatar Andreas Gohr Committed by GitHub
Browse files

Merge pull request #1868 from LarsGit223/master

Prevent duplicate "selected" attributes in option tag in Form.php (DropdownElement)
parents f7e8c7db 12a9bc03
No related branches found
No related tags found
No related merge requests found
......@@ -52,6 +52,9 @@ class OptGroup extends Element {
foreach($options as $key => $val) {
if (is_array($val)) {
if (!key_exists('label', $val)) throw new \InvalidArgumentException('If option is given as array, it has to have a "label"-key!');
if (key_exists('attrs', $val) && is_array($val['attrs']) && key_exists('selected', $val['attrs'])) {
throw new \InvalidArgumentException('Please use function "DropdownElement::val()" to set the selected option');
}
$this->options[$key] = $val;
} elseif(is_int($key)) {
$this->options[$val] = array('label' => (string) $val);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment