2

Rails - Online Display Form

 2 years ago
source link: https://www.codesd.com/item/rails-online-display-form.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Rails - Online Display Form

advertisements

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 %>
        </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.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK