Formtastic - customise blank option in select tag
I'm using fo开发者_StackOverflow中文版rmtastic to generate a list of options in a select tag (eg. :as => :select) and I want a "blank" option, but this creates an XHTML warning (i.e. trimming empty
Looking at the source, it looks like formtastic is generating:
<option value=""></option>
Is there a way to customise how formtastic generates blanks options?
maybe options :prompt could help you?
form.input :organization,
:collection => Organization.all(:order => :title),
:prompt => "some text"
have a good day!
Here are a answer with a similar issue :
Using :collection and :include_blank in Formtastic. How to do it?
He say if you add a :include_blank => true
, it will work... For example:
f.input(:author, :as => :select, :include_blank => true)
In my case, i have a has_and_belongs_to_many
association, and automatically have a blank option.
f.input :groups, :as => :check_boxes, :collection => current_admin_user.groups.order("created_at ASC").all
I follow this guide : https://github.com/justinfrench/formtastic#the-available-inputs
I hope to help!
精彩评论