4

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.

<select id="..." name="..." class="...">
    <option value="145">UK8</option>
</select>

I'd like it to be rendered as follows.

<select id="..." name="..." class="...">
    <option value="145" data-country="United Kingdom">UK8</option>
</select>

Is this possible?

2 Answers 2

5

There is Form Options Attributes module wich adds support for the attributes.

3

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

1
  • 1
    Hey Inamil, thanks for the reply and the SO link. I'll check it out and post back here.
    – Shalan
    Jul 29, 2013 at 9:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.