Rails - Display Form inline
I'm having trouble displaying a Rails form in a horizontal line.
I have a view, it contains a table, w/ in a table cell I render a partial containing the form I want to be inlined:
View:
<tr>
<td>
<%= @user.name %>
</td>
<td>
<a href="#">Add Item</a>
</td>
<td>
<%= render :partial => '/items/new_item' %>
</td>
</tr>
</table>
Partial (Form):
<%= form_for( Item.new ) do |f| %>
<div class="field">
<%= f.text_field :content %>
开发者_StackOverflow </div>
<div class="action">
<%= f.submit "Add Item", :class => 'item_submit' %>
</div>
<% end %>
I have tried:
form{
display:inline;
padding: 0px;
}
And also creating a Unordered list w/in the form, and making the text field and submit button list items, then in the css making the list inline. This didn't work either.
Thanks for the help!
If I understand you correct, you could try to use span instead of div, or set display:inline for div, not for form.
You could always float the divs in the form I.e.
form > div { float:left: display:inline-block;}
This worked for me:
<%= form_tag some_controller_path, method: 'POST', class: 'form-inline', style: 'display:inline !important;' do %>
... your form code here
<% end %>
精彩评论