views:

15

answers:

2

Hi,

How do you add a field set to a form_for method?

A: 

You need to have a new object or get an existing object from your dc since it is a 'form for' and then you create a form builder f and call methods on that form builder such as the following:

<% form_for(@object) do |f| %>
 <%= f.text_field :method_name %>
<% end %>
Sam
so something like<%= f.field_set 'test' %>
Brian
A: 

You can use field_set_tag. For example, using a generic 'user' object

For Rails 2.3.x

<% form_for(@user) do |f| %>

  <% field_set_tag 'Name' do %>
    <%= f.text_field :first_name %>
    <%= f.text_field :last_name %>
  <% end %>

<% end %>

And for Rails 3.0.0:

<%= form_for(@user) do |f| %>

  <%= field_set_tag 'Name' do %>
    <%= f.text_field :first_name %>
    <%= f.text_field :last_name %>
  <% end %>

<% end %>
theTRON
is that supposed to be <%= f.text_field %>?
Brian
great that worked thank you
Brian
Whoops, quite right - edited.
theTRON