Skip to content

Commit

Permalink
Refactor string input a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosantoniodasilva committed Nov 21, 2010
1 parent b33f136 commit c0e196e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/simple_form/inputs/string_input.rb
Expand Up @@ -4,13 +4,13 @@ class StringInput < Base
def input
input_html_options[:size] ||= [limit, SimpleForm.default_input_size].compact.min
input_html_options[:maxlength] ||= limit if limit
input_html_options[:type] ||= input_type unless input_type == :string
input_html_options[:type] ||= input_type unless string?

@builder.text_field(attribute_name, input_html_options)
end

def input_html_classes
input_type == :string ? super : super.unshift("string")
string? ? super : super.unshift("string")
end

protected
Expand All @@ -22,6 +22,10 @@ def limit
def has_placeholder?
placeholder_present?
end

def string?
input_type == :string
end
end
end
end

0 comments on commit c0e196e

Please sign in to comment.