Sha256: 88e7780628853d5c6795bef521320b607f1314a783a034e7142774303e12f342

Contents?: true

Size: 862 Bytes

Versions: 9

Compression:

Stored size: 862 Bytes

Contents

module Trestle
  class Form
    module Fields
      class FormControl < Field
        def render
          form_group do
            input_group do
              field
            end
          end
        end

        def input_group
          if @prepend || @append
            content_tag(:div, class: "input-group") do
              concat content_tag(:span, @prepend, class: "input-group-addon") if @prepend
              concat yield
              concat content_tag(:span, @append, class: "input-group-addon") if @append
            end
          else
            yield
          end
        end

        def defaults
          super.merge(class: ["form-control"])
        end

        def extract_options!
          super

          @prepend = options.delete(:prepend)
          @append  = options.delete(:append)
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
trestle-0.8.9 lib/trestle/form/fields/form_control.rb
trestle-0.8.8 lib/trestle/form/fields/form_control.rb
trestle-0.8.7 lib/trestle/form/fields/form_control.rb
trestle-0.8.6 lib/trestle/form/fields/form_control.rb
trestle-0.8.5 lib/trestle/form/fields/form_control.rb
trestle-0.8.4 lib/trestle/form/fields/form_control.rb
trestle-0.8.3 lib/trestle/form/fields/form_control.rb
trestle-0.8.2 lib/trestle/form/fields/form_control.rb
trestle-0.8.0 lib/trestle/form/fields/form_control.rb