Sha256: 3c241a91973e72a3d8912c62f943d8f6e50cdced52392f04401a7bce0cbe1fd5

Contents?: true

Size: 690 Bytes

Versions: 10

Compression:

Stored size: 690 Bytes

Contents

module BulmaFormBuilder
  module Helpers
    def alert_message(options = {})
      title = options[:title] || I18n.t('errors.messages.alert')
      css = options[:class] || 'notification is-danger'
      return unless object.respond_to?(:errors) && object.errors.full_messages.any?

      content_tag :div, class: css do
        concat content_tag :p, title
        concat error_summary unless options[:error_summary] == false
      end
    end

    def error_summary
      return unless object.errors.any?

      content_tag :ul, class: 'error-summary' do
        object.errors.full_messages.each do |error|
          concat content_tag(:li, error)
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
bulma_form_builder-0.4.3 lib/bulma_form_builder/helpers.rb
bulma_form_builder-0.4.2 lib/bulma_form_builder/helpers.rb
bulma_form_builder-0.4.1 lib/bulma_form_builder/helpers.rb
bulma_form_builder-0.4.0 lib/bulma_form_builder/helpers.rb
bulma_form_builder-0.3.1 lib/bulma_form_builder/helpers.rb
bulma_form_builder-0.3.0 lib/bulma_form_builder/helpers.rb
bulma_form_builder-0.2.1 lib/bulma_form_builder/helpers.rb
bulma_form_builder-0.2.0 lib/bulma_form_builder/helpers.rb
bulma_form_builder-0.1.1 lib/bulma_form_builder/helpers.rb
bulma_form_builder-0.1.0 lib/bulma_form_builder/helpers.rb