diff --git a/.template/addons/crud/lib/templates/slim/scaffold/_form.html.slim.tt b/.template/addons/crud/lib/templates/slim/scaffold/_form.html.slim.tt new file mode 100644 index 00000000..a87356e6 --- /dev/null +++ b/.template/addons/crud/lib/templates/slim/scaffold/_form.html.slim.tt @@ -0,0 +1,28 @@ += form_with(model: <%= model_resource_name %>) do |form| + - if <%= singular_table_name %>.errors.any? + div style="color: red" + h2 = "#{pluralize(<%= singular_table_name %>.errors.count, "error")} prohibited this <%= singular_table_name %> from being saved:" + ul + - <%= singular_table_name %>.errors.each do |error| + li = error.full_message + +<% attributes.each do |attribute| -%> + .mb-3 +<% if attribute.password_digest? -%> + = form.label :password, class: 'form-label' + = form.password_field :password, class: 'form-control' + + .mb-3 + = form.label :password_confirmation, class: 'form-label' + = form.password_field :password_confirmation, class: 'form-control' +<% elsif attribute.attachments? -%> + = form.label :<%= attribute.column_name %>, class: 'form-label' + = form.<%= attribute.field_type %> :<%= attribute.column_name %>, multiple: true, class: 'form-control' +<% else -%> + = form.label :<%= attribute.column_name %>, class: 'form-label' + = form.<%= attribute.field_type %> :<%= attribute.column_name %>, class: 'form-control' +<% end -%> + +<% end -%> + div + = form.submit 'Submit', class: 'btn btn-primary' diff --git a/.template/addons/crud/lib/templates/slim/scaffold/edit.html.slim.tt b/.template/addons/crud/lib/templates/slim/scaffold/edit.html.slim.tt new file mode 100644 index 00000000..a92dbb9b --- /dev/null +++ b/.template/addons/crud/lib/templates/slim/scaffold/edit.html.slim.tt @@ -0,0 +1,8 @@ +h1 Editing <%= human_name.downcase %> + +== render "form", <%= singular_table_name %>: @<%= singular_table_name %> + +br + +div + =< link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper(type: :path) %>, class: 'btn btn-secondary' diff --git a/.template/addons/crud/lib/templates/slim/scaffold/new.html.slim.tt b/.template/addons/crud/lib/templates/slim/scaffold/new.html.slim.tt new file mode 100644 index 00000000..fb11e144 --- /dev/null +++ b/.template/addons/crud/lib/templates/slim/scaffold/new.html.slim.tt @@ -0,0 +1,10 @@ +content_for :title, "New <%= human_name.downcase %>" + +h1 New <%= human_name.downcase %> + +== render 'form', <%= singular_table_name %>: @<%= singular_table_name %> + +br + +div + = link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper(type: :path) %>