- if model_object.errors.any? #error_explanation %ul - model_object.errors.full_messages.each do |msg| %li= msg - model_presenter.form_for(action).lines.each do |line| .row - line.each do |field| - nested_in = nil unless nested_in - if field.nested_form? .nested-form{:class => field.name} %h3.nested-form-title = t("activerecord.attributes.#{@model_presenter.full_model_name}.#{field.name}") .nested-form-actions = link_to_function t("nested_form.close"), "toggleNestedForm(this);" - if field.nested_form_modes?(:new) = " | " = link_to_function t("nested_form.new"), "createNewForm('.nested-form-list.#{field.name}', '#{field.name}')" - if field.nested_form_modes?(:associate) = " | " = link_to_function t("nested_form.existing_option"), "renderSelectOptions('.existing-options.#{field.name}')" .existing-options{:class => field.name} %h4.existing-options-title = t("nested_form.existing_option_title") - field_presenter = model_presenter.presenter_to_field(field, nil) = f.collection_check_boxes "#{field.name.singularize.to_sym}_ids".to_sym, field_presenter.model_class.list_for_checkbox, :first, :last %ul.nested-form-list{:class => field.name} %h4.nested-form-subtitle = t("nested_form.new_subtitle") - model_object.send(field.name).build = f.simple_fields_for field.name.to_sym do |inner_form| %li.nested-form-list-item{:class => "#{inner_form.object.id.nil? and inner_form.object.errors.size == 0 ? 'form-new-association' : 'form-existent-association'}" } .nested-form-list-item-actions = link_to_function t("remove"), "removeNestedFormElement(this);" if field.nested_form_allow_destroy? = inner_form.input :id, :as => :hidden = inner_form.input :_destroy, :as => :hidden, :input_html => {:class => "destroy"} if field.nested_form_allow_destroy? - nested_presenter = model_presenter.presenter_to_field(field, inner_form.object) = render '/carnival/shared/form/inner_form', button: t('update'), model_object: inner_form.object, model_presenter: nested_presenter, :nested_in => model_object, :f => inner_form, :action => action - else - if model_presenter.must_render_field?(nested_in, field, model_object) = render "/carnival/shared/form/field", f: f, field: field, model_presenter: model_presenter