===entity_code=== <%- @model.attributes.each do |attr| -%>
<%%= f.label :<%= attr.name %> %> <%%= f.<%= attr.form_field %> :<%= attr.name %> %>
<%- end # model.attributes.each -%> <%- @model.associations.each do |assoc| -%> <%- if assoc.belongs_to? -%>
<%%= f.label :<%= assoc.model2.singular_name.foreign_key %> %> <%%= f.select :<%= assoc.model2.singular_name.foreign_key %>, options_for_select( <%= assoc.model2.klass %>.order('<%= assoc.reference_field %> ASC').collect{ |c| [c.<%= assoc.reference_field %>, c.id] }, f.object.<%= assoc.model2.singular_name.foreign_key %> ), :prompt => '-- Select --' %>
<%- end # if -%> <%- if assoc.has_and_belongs_to_many? and assoc.composition? -%>
<%%- <%= assoc.model2.klass %>.order('<%= assoc.reference_field %> ASC').each do |<%= assoc.model2.singular_name %>| -%>
<%%= check_box_tag '<%= assoc.model2.plural_name %>[]', <%= assoc.model2.singular_name %>.id, (@<%= @model.singular_name %>.<%= assoc.model2.plural_name %>.include?(<%= assoc.model2.singular_name %>) ? true : false) %> <%%= <%= assoc.model2.singular_name %>.<%= assoc.reference_field %> %>
<%%- end -%>
<%- end -%> <%- if assoc.nested? -%>
<%%= f.fields_for :<%= (assoc.nested_many?) ? assoc.model2.plural_name : assoc.model2.singular_name %> do |ff| %> <%%= render '<%= assoc.model2.space %>/<%= assoc.model2.plural_name %>/form_fields', :f => ff %> <%- unless assoc.nested_one? -%> <%%= ff.link_to_remove t('nested.remove') %> <%- end -%> <%% end %> <%- unless assoc.nested_one? -%> <%%= f.link_to_add t('nested.add', :name => '<%= assoc.model2.singular_name %>'), :<%= assoc.model2.plural_name %> %> <%- end -%>
<%- end # if -%> <%- end # associations loop -%>