<p>If you take a look at the <a href="http://buildwithcraft.com/docs/plugins/field-types" rel="nofollow">FieldType</a> documentation it looks as the you need to create a template for the input field in which you can specify the actual html for your field. The example in the documentation is for a <code>textarea</code> but in your case you can substitute this for a <code>select</code>. </p>

<p>Then once you've done that just override the <code>getInputHtml</code> method to render your new template.</p>

CC BY-SA 3.0
2015-06-17T15:57:08.837Z
Thank you for your answer, but I would like to get my custom field `ethnicOrigin` which options are comming from the database.
Alex
CC BY-SA 3.0
2015-06-17T16:48:29.213Z
I've updated the answer, that should be more useful to you.
Steve Holland
CC BY-SA 3.0
2015-06-17T15:40:25.553Z
2015-06-17T16:47:55.633Z
2015-06-17T16:47:55.633Z
Steve Holland
<p>In my template I have this,</p>

<pre><code>{{ 
    craft.fields
    .getFieldByHandle('ethnicOrigin')
    .getFieldType()
    .getInputHtml( 'fields[ethnicOrigin]', '') | raw
}}
</code></pre>

<p>which returns me a <code>&lt;select&gt;</code> html element Is it possible to add specific class to this select and or <code>data-</code> attribute?</p>

<field><custom-fieldtype>
How can I add attributes to craft field?
# How can I add attributes to craft field?

(Asked by: username_0 on 2015-06-17)

In my template I have this,
{{ 
    craft.fields
    .getFieldByHandle('ethnicOrigin')
    .getFieldType()
    .getInputHtml( 'fields[ethnicOrigin]', '') | raw
}}

which returns me a  html element Is it possible to add specific class to this select and or data- attribute?

**Tags:** field, custom-fieldtype


---

## 1 answers

### Answer by username_1 on 2015-06-17. Score: 2 | Accepted answer

If you take a look at the [FieldType](http://buildwithcraft.com/docs/plugins/field-types) documentation it looks as the you need to create a template for the input field in which you can specify the actual html for your field. The example in the documentation is for a `textarea` but in your case you can substitute this for a `select`.

Then once you've done that just override the `getInputHtml` method to render your new template.

> **Comments:**
> **username_0**: Thank you for your answer, but I would like to get my custom field `ethnicOrigin` which options are comming from the database.  
> **username_1**: I've updated the answer, that should be more useful to you.  

---

