1

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?

| improve this question | | | | |
2

If you take a look at the FieldType 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.

| improve this answer | | | | |
  • Thank you for your answer, but I would like to get my custom field ethnicOrigin which options are comming from the database. – Alex Jun 17 '15 at 15:57
  • I've updated the answer, that should be more useful to you. – Steve Holland Jun 17 '15 at 16:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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