Sha256: b4a7fbeba97956a305a9546b43f74b61df5b9a818400615e488d6dfc711f23f4

Contents?: true

Size: 893 Bytes

Versions: 6

Compression:

Stored size: 893 Bytes

Contents

require 'bootstrap_form'

module BootstrapValidatorRails
  class FormBuilder < BootstrapForm::FormBuilder
    def initialize(object_name, object, template, options)
      @attributes = BootstrapValidatorRails::Validators::Attributes.new(object)
      super
    end

    FIELD_HELPERS.each do |method_name|
      define_method(method_name) do |method, options = {}|
        attribute = @attributes.validator_data(method)
        options[:data] ||= {}
        options[:data] = options[:data].merge(attribute)
        super(method, options)
      end
    end

    def check_box(method, options = {}, checked_value = "1", unchecked_value = "0", &block)
      options[:data] ||= {}
      attribute = @attributes.validator_data(method)
      options[:data] = options[:data].merge(attribute)
      options[:include_hidden] = false
      content_tag :div, super, class: 'form-group'
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
bootstrap_validator_rails-1.1.0 lib/bootstrap_validator_rails/form_builder.rb
bootstrap_validator_rails-1.0.0 lib/bootstrap_validator_rails/form_builder.rb
bootstrap_validator_rails-0.7.0 lib/bootstrap_validator_rails/form_builder.rb
bootstrap_validator_rails-0.6.0 lib/bootstrap_validator_rails/form_builder.rb
bootstrap_validator_rails-0.5.1 lib/bootstrap_validator_rails/form_builder.rb
bootstrap_validator_rails-0.5.0 lib/bootstrap_validator_rails/form_builder.rb