<%= render_crud do %> <%unless params[:render] == 'modal'%> <% url = "#{@url}/#{@record.new_record? ? 'create' : @record.id.to_s+'/create'}?page=#{params[:page]}" %> <% remote_form = false%> <%else%> <% url = "#{@url}/#{@record.new_record? ? 'create?render=modal' : @record.id.to_s+'/create?render=modal'}" %> <% remote_form = true%> <%end%> <%= simple_nested_form_for @record, remote: remote_form, html: {class: "form-horizontal"}, url: url do |f| %> <%= flash_messages_error(@record.errors) %> <%@crud_helper.form_fields.each do |field|%> <% if field[:sf].present? && field[:sf][:if].present? %> <% next unless field[:sf][:if].call(f.object) %> <% end %> <% if field[:sf].present? && field[:sf][:grupo].present? %> <%= render "/crud/form_group", f: f, key: field[:attribute], groups: field[:sf] %> <% else %> <% if @model.reflect_on_association(field[:attribute]).try(:macro) == :belongs_to && is_raro_crud(@model.reflect_on_association(field[:attribute]).class_name) && field[:sf][:add_registro].nil?%> <%= render_plus_button(field,f,@model,@record) %> <%else%> <%= render_field(field,f,@model,@record) %> <%end%> <% end %> <% end %> <%@crud_helper.form_groups.each do |key, groups|%> <%= render "/crud/form_group", f: f, key: key, groups: groups %> <% end %>
<%= f.submit "Salvar", class: 'btn btn-primary' %> <%unless params[:render] == 'modal'%> <%= link_to "Voltar", "#{@url}?page=#{params[:page]}", class: 'btn btn-default', data: {push: 'partial', target: "#form"} %> <% end %>
<% end %> <% @crud_helper.form_scripts.each do |script| %> <%= javascript_include_tag "crud/#{script}" %> <% end %> <% end %>