Add attributes to options elements in a select box I am working with a Drupal 7 site; I have a vocabulary setup with an additional text field. On one of my content-type nodes, this is rendered as a drop-down select box with all the terms under that vocabulary. However, I would also like for the additional vocabulary field to be included as a data-country attribute. It is rendered rendered as follows.

&lt;select id="..." name="..." class="..."&gt;
    &lt;option value="145"&gt;UK8&lt;/option&gt;
&lt;/select&gt;


I'd like it to be rendered as follows.

&lt;select id="..." name="..." class="..."&gt;
    &lt;option value="145" data-country="United Kingdom"&gt;UK8&lt;/option&gt;
&lt;/select&gt;


Is this possible?
Unfotunately there is no way to do it using Form API. You need to involve some theming. Please check the following answer:

https://stackoverflow.com/a/9264589/2620782