_form.html.erb 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <%%= simple_form_for(@<%= singular_table_name %>) do |f| %>
  2. <%% if <%= singular_table_name %>.errors.any? %>
  3. <div id="error_explanation">
  4. <h2><%%= pluralize(<%= singular_table_name %>.errors.count, "error") %> prohibited this <%= singular_table_name %> from being saved:</h2>
  5. <ul>
  6. <%% <%= singular_table_name %>.errors.full_messages.each do |message| %>
  7. <li><%%= message %></li>
  8. <%% end %>
  9. </ul>
  10. </div>
  11. <%% end %>
  12. <div class="form-inputs">
  13. <% attributes.each do |attribute| -%>
  14. <% if attribute.password_digest? -%>
  15. <%%= f.input :password %>
  16. <%%= f.input :password_confirmation %>
  17. <% else -%>
  18. <%%= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %> %>
  19. <% end -%>
  20. <% end -%>
  21. </div>
  22. <div class="form-actions">
  23. <%% if <%= model_resource_name %>.persisted? %>
  24. <div class="float-right">
  25. <%%= link_to 'Destroy', <%= model_resource_name %>, method: :delete, class: "text-danger", data: { confirm: 'Are you sure?' } %>
  26. </div>
  27. <%% end %>
  28. <%%= f.submit class: 'btn btn-primary' %>
  29. <%% if <%= model_resource_name %>.persisted? %>
  30. <%%= link_to "Cancel", <%= model_resource_name %>, class: "btn btn-link" %>
  31. <%% else %>
  32. <%%= link_to "Cancel", <%= index_helper %>_path, class: "btn btn-link" %>
  33. <%% end %>
  34. </div>
  35. <%% end %>