Class: Decidim::ValidationErrorsPresenter
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Decidim::ValidationErrorsPresenter
- Includes:
- SanitizeHelper
- Defined in:
- app/presenters/decidim/validation_errors_presenter.rb
Overview
Decorator to format validation errors of a form in html format
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#form ⇒ Object
readonly
Returns the value of attribute form.
Instance Method Summary collapse
-
#initialize(error, form) ⇒ ValidationErrorsPresenter
constructor
A new instance of ValidationErrorsPresenter.
- #message ⇒ Object
- #validation_errors_list ⇒ Object
Methods included from SanitizeHelper
#decidim_html_escape, #decidim_sanitize, #decidim_sanitize_admin, #decidim_sanitize_editor, #decidim_sanitize_editor_admin, #decidim_sanitize_newsletter, #decidim_url_escape, included
Constructor Details
#initialize(error, form) ⇒ ValidationErrorsPresenter
Returns a new instance of ValidationErrorsPresenter.
12 13 14 15 |
# File 'app/presenters/decidim/validation_errors_presenter.rb', line 12 def initialize(error, form) @error = error @form = form end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
10 11 12 |
# File 'app/presenters/decidim/validation_errors_presenter.rb', line 10 def error @error end |
#form ⇒ Object (readonly)
Returns the value of attribute form.
10 11 12 |
# File 'app/presenters/decidim/validation_errors_presenter.rb', line 10 def form @form end |
Instance Method Details
#message ⇒ Object
17 18 19 |
# File 'app/presenters/decidim/validation_errors_presenter.rb', line 17 def "<p>#{error}</p>#{validation_errors_list}" end |
#validation_errors_list ⇒ Object
21 22 23 24 25 |
# File 'app/presenters/decidim/validation_errors_presenter.rb', line 21 def validation_errors_list return "" if form.valid? content_tag(:ul, decidim_sanitize(form.errors..map { |err| content_tag(:li, err) }.join)) end |