Sha256: 97f5e51e441d0bd8089db3a2195f2e7b1056bfc8bfc9586f4589b0c51f02d92a

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

# -*- encoding: utf-8 -*-
# -*- frozen_string_literal: true -*-
# -*- warn_indent: true -*-

module RailsBootstrapForm
  class BootstrapFormBuilder < ActionView::Helpers::FormBuilder

    include RailsBootstrapForm::FieldWrapperBuilder
    include RailsBootstrapForm::Components
    include RailsBootstrapForm::InputGroupBuilder
    include RailsBootstrapForm::Inputs

    delegate :capture, :concat, :tag, to: :@template

    attr_accessor :bootstrap_form_options

    def initialize(object_name, object, template, options)
      @bootstrap_form_options = RailsBootstrapForm::BootstrapFormOptions.new(options.delete(:bootstrap_form))
      apply_default_form_options(options)
      super(object_name, object, template, options)
    end

    def apply_default_form_options(options)
      options[:html] ||= {}
      options[:html].reverse_merge!(RailsBootstrapForm.config.default_form_attributes)
    end

    def control_specific_class(field_tag_name)
      "rails-bootstrap-forms-#{field_tag_name.to_s.tr("_", "-")}"
    end

    private :apply_default_form_options, :control_specific_class
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rails_bootstrap_form-0.5.0 lib/rails_bootstrap_form/bootstrap_form_builder.rb
rails_bootstrap_form-0.4.2 lib/rails_bootstrap_form/bootstrap_form_builder.rb
rails_bootstrap_form-0.4.1 lib/rails_bootstrap_form/bootstrap_form_builder.rb
rails_bootstrap_form-0.4.0 lib/rails_bootstrap_form/bootstrap_form_builder.rb