Class: ApplicationForm

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

Instance Method Summary collapse

Methods inherited from Protoform::Rails::Form

#assign, #collection, #field, #form_tag, #key, #namespace, #serialize, #submit, #view_template

Instance Method Details

#around_template(&block) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/generators/protoform/install/templates/application_form.rb', line 23

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

#error_messagesObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/generators/protoform/install/templates/application_form.rb', line 31

def error_messages
  return if model.errors.none?

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

#row(component) ⇒ Object

These are the current dry-initializer options for the base class:

param :model, reader: false option :helpers, reader: false, default: -> {} option :action, reader: false, default: -> {} option :method, reader: false, default: -> {} option :namespace, reader: false, default: -> do

Namespace.root(key, object: @model, field_class: self.class::Field)

end



16
17
18
19
20
21
# File 'lib/generators/protoform/install/templates/application_form.rb', line 16

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