Sha256: 9fc5436162705febb43bbc4b2d26733d147dc2fe3a60bcc3bf43b9ec1aca3593

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

module BulmaFormBuilder
  module Inputs
    module CheckBox
      extend ActiveSupport::Concern

      include Base

      included do
        def check_box_with_bulma(name, options = {}, checked_value = '1', unchecked_value = '0', &block)
          options = options.symbolize_keys!
          check_box_options = options.except(:class, :label, :label_class, :error_message, :help, :inline, :custom, :hide_label, :skip_label, :wrapper_class)

          content_tag(:div, class: 'field') do
            content_tag(:label, class: 'checkbox') do
              html = check_box_without_bulma(name, check_box_options, checked_value, unchecked_value)
              html.concat(check_box_label(name)) unless options[:skip_label]
              html.concat(generate_error(name)) if options[:error_message]
              html
            end
          end
        end

        bulma_alias(:check_box)
      end

      private

      def check_box_label(name)
        content_tag(:span, object.class.human_attribute_name(name), class: 'control-label')
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bulma_form_builder-0.2.0 lib/bulma_form_builder/inputs/check_box.rb
bulma_form_builder-0.1.1 lib/bulma_form_builder/inputs/check_box.rb
bulma_form_builder-0.1.0 lib/bulma_form_builder/inputs/check_box.rb