Placeholder in rails simpleform association doesn't work. I have tried a different ways but nothing works for me. And this way does't work:
<%= f.association :sex, :placeholder => 'sex' %>
Assuming the association field is a select (i.e. a drop down field), this may work for you:
<%= f.association :sex, prompt: 'sex' %>
I believe :placeholder is used for text input fields, (like the email and password fields in this bootstrap example: http://getbootstrap.com/css/#forms), while :prompt is used for select fields.
I hope this helps.
@gmrash what is your association rendering, a select with a list of items? This is the default, and html selects do not have the placeholder attribute, as you can see in this simple test on the console:
'placeholder' in document.createElement('input')
=> true
'placeholder' in document.createElement('select')
=> false
I believe you're looking for either include_blank or prompt options, please take a look at Rails collection_select to see which options are available (which is what's used by Simple Form).
I'm giving it a close, but please let me know if you're still having issues and we might reopen if needed. Thanks.
Most helpful comment
Assuming the association field is a select (i.e. a drop down field), this may work for you:
<%= f.association :sex, prompt: 'sex' %>I believe
:placeholderis used for text input fields, (like the email and password fields in this bootstrap example: http://getbootstrap.com/css/#forms), while:promptis used for select fields.I hope this helps.