liver
liver

Reputation: 498

Formtastic belongs_to select tag generates a blank selection option

I'm using Formtastic as a semantic_form_for books and lists. Each list has_many books and each book belongs_to a list. When the user creates a new book, they can choose what list to add the book to. Here is my form code:

<%= semantic_form_for(@book) do |f| %>
    <p>Select a list to add this book to: </p>
    <%= f.input :list, :as => :select %>
    ...
    <%= f.submit "Add book", class: "btn btn-default" %>
<% end %>

The only problem is that the select tag that is generated has a blank option for select at the top. So the options for select look like this:

I don't want there to be an extra space. How can I fix that?

Here is a picture:

enter image description here

Upvotes: 0

Views: 140

Answers (1)

SRod
SRod

Reputation: 135

I think what you're looking for is include_blank. So it'd be something like this: <%= f.input :list, :as => :select, :include_blank => false %>

Upvotes: 1

Related Questions