add haml _form file and copy it into place if app template engine is haml
This commit is contained in:
parent
2a1b232c28
commit
df6ec5ea66
|
@ -13,8 +13,12 @@ module SimpleForm
|
|||
end
|
||||
|
||||
def copy_scaffold_template
|
||||
if Rails::Generators.options[:rails][:template_engine] == :haml
|
||||
copy_file '_form.html.haml', 'lib/templates/haml/scaffold/_form.html.haml'
|
||||
else
|
||||
copy_file '_form.html.erb', 'lib/templates/erb/scaffold/_form.html.erb'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,18 @@
|
|||
= simple_form_for(@<%= singular_name %>) do |f|
|
||||
- if @<%= singular_name %>.errors.any?
|
||||
#error_explanation
|
||||
%h2
|
||||
= pluralize(@<%= singular_name %>.errors.count, "error")
|
||||
prohibited this <%= singular_name %> from being saved:
|
||||
|
||||
%ul
|
||||
- @<%= singular_name %>.errors.full_messages.each do |msg|
|
||||
%li= msg
|
||||
|
||||
.inputs
|
||||
<%- attributes.each do |attribute| -%>
|
||||
= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %>
|
||||
<%- end -%>
|
||||
|
||||
.actions
|
||||
= f.button :submit
|
Loading…
Reference in New Issue