adamwathan / form

Super basic form HTML builder, only really exists so I can pull it in for some other more useful projects.
MIT License
232 stars 117 forks source link

Made ability to add option attributes for the Select element. #123

Closed bupy7 closed 6 years ago

bupy7 commented 7 years ago

Option attributes is very important feature for Select element. I have added it to one element. Now, we can do follow:

echo (new Select('age', ['10' => 'Teen', 20 => 'Twenty'])->setOptAttributes([10 => ['data-key' => 'some-key']]);

and we got result:

<select name="age">
    <option value="10" data-key="some-key">Teen</option>
    <option value="20">Twenty</option>
</select>

It's beaniful, isn't it? =)

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.2%) to 95.248% when pulling 5933c7ac2b0c36b6cd1f518598590e5ac93c5779 on bupy7:select-opt-attribute into a2188f252354e4ec3312a673da38529ad15da8cd on adamwathan:master.