Working on a rails form generator. As easy as:
<%= easy_form_for(@user) %>
or as advanced as:
<%= easy_form_for(@user,
:only => [:name, (:username if @user.username.blank?), :email, :birthday, :city, :state_id, :zipcode, :country_id, :bio, :diet_id, :me_gender, :you_gender],
:field_options => {
:email => {:type => "email", :autocapitalize => "off"},
:submit => {:disable_with => "Saving…".html_safe, :class => "button white full"},
:birthday => {
:order => [:month, :day, :year],
:start_year => 12.years.ago.year,
:end_year => 60.years.ago.year,
:include_blank => true},
:me_gender => {:label => "My Gender"},
:you_gender => {:label => "Desired Gender"}
}) do |f| %>
<%= f.label :label_id, "My Straightedginess" %>
<% Label.all.each do |label| %>
<%= f.radio_button :label_id, label.id, :checked => @user.label == label %> |
<%= f.label "label_id_#{label.id}", label.name.titleize %> |
<% end %>
<%= f.label :your_labels_attributes, "Desired Straightedginess" %>
<% Label.all.each_with_index do |label, index| %>
<%= f.fields_for "your_labels_attributes[#{index}]", :child_index => index do |ff| %>
<% if @user.desired_labels.include? label %>
<%# HACK remove find from view, do it in the controller %>
<%= ff.hidden_field :id, :value => @user.your_labels.where(:label_id => label.id).first.id, :style => "display:none" %>
<%= ff.check_box :_destroy, { :checked => true }, 0, 1 %> |
<%= ff.label :_destroy, label.name.titleize %> |
<% else %>
<%= ff.check_box :label_id, {}, label.id %> |
<%= ff.label :label_id, label.name.titleize %> |
<% end %>
<% end %>
<% end %>
<% end %>