Class: ApplicationForm

Inherits:
Superform::Rails::Form show all
Includes:
Phlex::Rails::Helpers::Pluralize
Defined in:
lib/generators/superform/install/templates/application_form.rb

Instance Attribute Summary

Attributes inherited from Superform::Rails::Form

#model

Instance Method Summary collapse

Methods inherited from Superform::Rails::Form

#form_tag, #initialize, #key, #submit, #template

Constructor Details

This class inherits a constructor from Superform::Rails::Form

Instance Method Details

#around_templateObject



11
12
13
14
15
16
17
# File 'lib/generators/superform/install/templates/application_form.rb', line 11

def around_template(&)
  super do
    error_messages
    yield
    submit
  end
end

#error_messagesObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/generators/superform/install/templates/application_form.rb', line 19

def error_messages
  if model.errors.any?
    div(style: "color: red;") do
      h2 { "#{pluralize model.errors.count, "error"} prohibited this post from being saved:" }
      ul do
        model.errors.each do |error|
          li { error.full_message }
        end
      end
    end
  end
end

#row(component) ⇒ Object



4
5
6
7
8
9
# File 'lib/generators/superform/install/templates/application_form.rb', line 4

def row(component)
  div do
    render component.field.label(style: "display: block;")
    render component
  end
end