2
votes

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?

2
I simplified the code for the sake of saninty =)razenha

2 Answers

4
votes

You can to use

SimpleForm.wrapper_tag = :fieldset

or

f.association :field, :wrapper_tag => :fieldset
1
votes

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