Sha256: 11e0f4c9aa420955e26d61ed1eadcf23b8dc6f7854ec54cb73e780e87457bc0c

Contents?: true

Size: 871 Bytes

Versions: 1

Compression:

Stored size: 871 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,
            :placeholder => placeholder_text
          }.merge(super)
        end
        
        def placeholder_text
          localized_string(method, options[:placeholder], :placeholder)
        end
        
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nuatt-formtastic-0.2.3 lib/formtastic/inputs/base/stringish.rb