Sha256: d5123fa58b80bccdf5c5b364b432170551686165b2a6e6f76f4452a71681f1ff

Contents?: true

Size: 586 Bytes

Versions: 25

Compression:

Stored size: 586 Bytes

Contents

# frozen_string_literal: true

module Decidim
  #
  # Decorator to format validation errors of a form in html format
  #
  class ValidationErrorsPresenter < SimpleDelegator
    include Decidim::SanitizeHelper

    attr_reader :error, :form

    def initialize(error, form)
      @error = error
      @form = form
    end

    def message
      "<p>#{error}</p>#{validation_errors_list}"
    end

    def validation_errors_list
      return "" if form.valid?

      content_tag(:ul, decidim_sanitize(form.errors.full_messages.map { |err| content_tag(:li, err) }.join))
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
decidim-core-0.29.1 app/presenters/decidim/validation_errors_presenter.rb
decidim-core-0.28.4 app/presenters/decidim/validation_errors_presenter.rb
decidim-core-0.27.9 app/presenters/decidim/validation_errors_presenter.rb
decidim-core-0.29.0 app/presenters/decidim/validation_errors_presenter.rb
decidim-core-0.28.3 app/presenters/decidim/validation_errors_presenter.rb
decidim-core-0.27.8 app/presenters/decidim/validation_errors_presenter.rb
decidim-core-0.29.0.rc4 app/presenters/decidim/validation_errors_presenter.rb
decidim-core-0.29.0.rc3 app/presenters/decidim/validation_errors_presenter.rb
decidim-core-0.29.0.rc2 app/presenters/decidim/validation_errors_presenter.rb
decidim-core-0.29.0.rc1 app/presenters/decidim/validation_errors_presenter.rb
decidim-core-0.28.2 app/presenters/decidim/validation_errors_presenter.rb
decidim-core-0.27.7 app/presenters/decidim/validation_errors_presenter.rb
decidim-core-0.28.1 app/presenters/decidim/validation_errors_presenter.rb
decidim-core-0.27.6 app/presenters/decidim/validation_errors_presenter.rb
decidim-core-0.28.0 app/presenters/decidim/validation_errors_presenter.rb
decidim-core-0.27.5 app/presenters/decidim/validation_errors_presenter.rb
decidim-core-0.28.0.rc5 app/presenters/decidim/validation_errors_presenter.rb
decidim-core-0.28.0.rc4 app/presenters/decidim/validation_errors_presenter.rb
decidim-core-0.27.4 app/presenters/decidim/validation_errors_presenter.rb
decidim-core-0.27.3 app/presenters/decidim/validation_errors_presenter.rb