[dokuwiki] New PR: Prevent duplicate "selected" attributes in option tag in Form.php (DropdownElement)

  • From: "LarsGit223" <wiki@xxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Wed, 22 Feb 2017 21:25:12 +0100 (CET)

Hi,

LarsGit223 opened a new pull request at 
https://github.com/splitbrain/dokuwiki/pull/1868:

Throw an exception if an attribute array including the attribute ```selected``` 
is given to ```OptGroup::options()``` as this could lead to an ```<option>``` 
tag having two ```selected``` attributes or having two ```<option>``` tags with 
an ```selected``` attribute in the option group.

The exception prompts the developer to use ```DropdownElement::val()``` to set 
the selected option of an drop down list.

Some example code causing the exception would be:
```
// Select user from drop down list
$filter = array();
$filter['grps'] = $selectUserGroup;
$options = array();
foreach ($auth->retrieveUsers(0, 0, $filter) as $curr_user) {
    if ($curr_user != 'testuser') {
        $options [] = $curr_user['name'];
    } else {
        $options [] = array ('label' => $curr_user['name'],
    }                        'attrs' => array('selected' => 'selected'));
}
$input = $form->addDropdown('user', $options, NULL, $pos++);
$input->val($INFO['userinfo']['name']);
```

Please help us to review this pull request, so new contributors get feedback in 
a timely manner.

0266ed80-f93d-11e6-9ac6-d71b179cc4c2


-- 
DokuWiki mailing list - more info at
http://www.dokuwiki.org/mailinglist

Other related posts:

  • » [dokuwiki] New PR: Prevent duplicate "selected" attributes in option tag in Form.php (DropdownElement) - LarsGit223