Class: Components::Form
- Inherits:
-
Superform::Rails::Form
- Object
- Superform::Rails::Form
- Components::Form
- Includes:
- Phlex::Rails::Helpers::Pluralize
- Defined in:
- lib/generators/superform/install/templates/base.rb
Defined Under Namespace
Classes: Field
Constant Summary
Constants inherited from Superform::Rails::Form
Instance Attribute Summary
Attributes inherited from Superform::Rails::Form
Instance Method Summary collapse
- #around_template ⇒ Object
-
#error_messages ⇒ Object
Displays error messages for the form's model if there are any validation errors.
-
#row(component) ⇒ Object
Wraps a form field and its label in a div for layout purposes.
Methods inherited from Superform::Rails::Form
#build_field, #form_tag, #initialize, #key, #submit, #view_template
Constructor Details
This class inherits a constructor from Superform::Rails::Form
Instance Method Details
#around_template ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/generators/superform/install/templates/base.rb', line 22 def around_template(&) super do # Renders error messages if there are any validation errors on the model # Renders the contents of the form from `view_template` or the block passed # the #render method. yield if block_given? # Renders the submit button for the form. submit end end |
#error_messages ⇒ Object
Displays error messages for the form's model if there are any validation errors.
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/generators/superform/install/templates/base.rb', line 38 def 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. } end end end end end |
#row(component) ⇒ Object
Wraps a form field and its label in a div for layout purposes.
52 53 54 55 56 57 |
# File 'lib/generators/superform/install/templates/base.rb', line 52 def row(component) div do render component.field.label(style: "display: block;") render component end end |