Sha256: d44994e013f99ea6355206ff233d1bbf4c35d71a48afe328df7848cabf08438e

Contents?: true

Size: 680 Bytes

Versions: 15

Compression:

Stored size: 680 Bytes

Contents

module Trestle
  class Form
    module Fields
      class StaticField < Field
        attr_reader :value

        def initialize(builder, template, name, value=nil, options={}, &block)
          if block_given? && value.is_a?(Hash)
            options = value
          else
            @value = value
          end

          super(builder, template, name, options, &block)
        end

        def field
          if block
            template.capture(&block)
          else
            content_tag(:p, value, class: "form-control-static")
          end
        end
      end
    end
  end
end

Trestle::Form::Builder.register(:static_field, Trestle::Form::Fields::StaticField)

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
trestle-0.9.1 lib/trestle/form/fields/static_field.rb
trestle-0.9.0 lib/trestle/form/fields/static_field.rb
trestle-0.8.13 lib/trestle/form/fields/static_field.rb
trestle-0.8.12 lib/trestle/form/fields/static_field.rb
trestle-0.8.11 lib/trestle/form/fields/static_field.rb
trestle-0.8.10 lib/trestle/form/fields/static_field.rb
trestle-0.8.9 lib/trestle/form/fields/static_field.rb
trestle-0.8.8 lib/trestle/form/fields/static_field.rb
trestle-0.8.7 lib/trestle/form/fields/static_field.rb
trestle-0.8.6 lib/trestle/form/fields/static_field.rb
trestle-0.8.5 lib/trestle/form/fields/static_field.rb
trestle-0.8.4 lib/trestle/form/fields/static_field.rb
trestle-0.8.3 lib/trestle/form/fields/static_field.rb
trestle-0.8.2 lib/trestle/form/fields/static_field.rb
trestle-0.8.0 lib/trestle/form/fields/static_field.rb