Class: Phlexi::Form::Components::FormErrors

Inherits:
HTML
  • Object
show all
Defined in:
lib/phlexi/form/components/form_errors.rb

Direct Known Subclasses

Base::Errors

Instance Method Summary collapse

Constructor Details

#initialize(message, errors) ⇒ FormErrors

Returns a new instance of FormErrors.



7
8
9
10
# File 'lib/phlexi/form/components/form_errors.rb', line 7

def initialize(message, errors)
  @message = message
  @errors = errors
end

Instance Method Details

#view_templateObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/phlexi/form/components/form_errors.rb', line 12

def view_template
  div(class: themed(:form_errors_wrapper, nil), role: "alert") do
    div(class: themed(:form_errors_inner_wrapper, nil)) do
      p(class: themed(:form_errors_message, nil)) { @message }
      ul(class: themed(:form_errors_list, nil)) do
        @errors.each do |error|
          li(class: themed(:form_errors_list_item, nil)) {
            error.to_s
          }
        end
      end
    end
  end
end