Sha256: e6ef071436224950b79c4247c9d230d8203f7ff742ffe6bc475f505b6a15392c

Contents?: true

Size: 867 Bytes

Versions: 4

Compression:

Stored size: 867 Bytes

Contents

module Formtastic
  module Inputs
    module Base
      module Stringish
      
        # @abstract Override this method in your input class to describe how the input should render itself.
        def to_html
          input_wrapping do
            label_html <<
            builder.text_field(method, input_html_options)
          end
        end
        
        # Overrides standard `input_html_options` to provide a `maxlength` and `size` attribute.
        def input_html_options
          {
            :maxlength => options[:input_html].try(:[], :maxlength) || limit,
            :size => builder.default_text_field_size
          }.merge(super)
        end
        
        def wrapper_html_options
          new_class = [super[:class], "stringish"].compact.join(" ")
          super.merge(:class => new_class)
        end
        
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
formtastic-2.1.1 lib/formtastic/inputs/base/stringish.rb
formtastic-2.1.0 lib/formtastic/inputs/base/stringish.rb
formtastic-2.1.0.rc lib/formtastic/inputs/base/stringish.rb
formtastic-2.1.0.beta1 lib/formtastic/inputs/base/stringish.rb