feature request - optional wrappers for label and input

28 views
Skip to first unread message

AppleII717

unread,
Jan 11, 2011, 1:53:30 PM1/11/11
to SimpleForm
You have optional wrappers for collections and collection items, why
not for labels and inputs[+components]?

While css can do a lot, and I stay away from tables in most cases,
nothing can beat what:

<tr><th>LABEL-CONTENT</th><td>INPUT+COMPONENT-CONTENT</td><tr>

gives you in handling long label, textarea, etc.

I've floated too many labels and inputs to try to get the same
controls and you can with a table and you alway find that instance
that does not fit and wraps.

Steve

AppleII717

unread,
Jan 12, 2011, 10:05:24 AM1/12/11
to SimpleForm
A little bit of a kludge, but I could not see anyway I could overload
it, especially since the label and input can be separate.

For my special use with the input call, I just wrap the simple_form
call in a table, set SimpleForm.wrapper_tag = :tr. Then wrote a
helper:

def simple_form_row(content)
content.gsub(/<label/,"<th").gsub(/<\/label>/,"</th><td>").gsub(/<
\/tr>/,"</td></tr>")
end

<% SimpleForm.wrapper_tag = :tr %>
<table>
<%= f.simple_fields_for :posts do |posts_form| %>
<%= simple_form_row(posts_form.input :title) %>
<%= simple_form_row(posts_form.input :name) %>
<% end %>
</table>

CSS takes care of the rest.
Reply all
Reply to author
Forward
0 new messages