Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-17T15:57:08.837Z
Answers.Text: Thank you for your answer, but I would like to get my custom field `ethnicOrigin` which options are comming from the database.
Answers.UserDisplayName: Alex
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-17T16:48:29.213Z
Answers.Text: I've updated the answer, that should be more useful to you.
Answers.UserDisplayName: Steve Holland
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-17T15:40:25.553Z
Answers.LastActivityDate: 2015-06-17T16:47:55.633Z
Answers.LastEditDate: 2015-06-17T16:47:55.633Z
Answers.UserDisplayName: Steve Holland
Body: <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>
  
Tags: <field><custom-fieldtype>
Title: How can I add attributes to craft field?
ThreadText: # 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 `<select>` 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.  
  
  ---
  
  