I'm using the simple_form gem in Rails 3.1 app and I want do customize the way the associations are displayed.
Today, for this code:
<%= f.association :grupos, :include_blank => false, :label_method => :nome, :as => :check_boxes %>
simple_form does something like that:
<div><label>Grupos<label><span><input name="user[grupo_ids][]" type="checkbox" value="1" /><label for="user_grupo_ids_1">Nome do Grupo</label></span></div>
So, it wraps the association HTML code in and puts the name of the association in a
I want to put the association HTML code in and show the name of the association inside a
Something like that:
<fieldset><legend>Grupos</legend><span><input name="user[grupo_ids][]" type="checkbox" value="1" /><label for="user_grupo_ids_1">Nome do Grupo</label></span></fieldset>
Is it possible to customize simple_form to do that without change it's internal code or monkey-patching it?
You can to use
SimpleForm.wrapper_tag = :fieldset
or
f.association :field, :wrapper_tag => :fieldset
Unfortunately you can't change label tag to legend tag which should be there instead label tag.
You can do this:
%fieldset
%legend Title of legend
f.association :grupos, :include_blank => false, :label => false, :as => :check_boxes
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.