Optimize redundant code

Hello,

I would like to wrap the class type-text around each label/text_field.
There must be a better way than my example below? I don’t know how to
do this without an object to loob through :slight_smile:

<% content_tag :div, :class => “type-text” do -%>
<%= label(:user, :login, “Username”) %><%= f.text_field :login %>
<% end %>

<% content_tag :div, :class => “type-text” do -%>
<%= label(:user, :firstname, “Firstname”) %><%=
f.text_field :firstname %>
<% end %>

<% content_tag :div, :class => “type-text” do -%>
<%= label(:user, :lastname, “Lastname”) %><%= f.text_field :lastname
%>
<% end %>

Best regards.
Asbjørn Morell.

What you need is a custom form buider →
http://onrails.org/articles/2008/06/13/advanced-rails-studio-custom-form-builder

Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/
(en)