Refactor string input a bit

This commit is contained in:
Carlos Antonio da Silva 2010-11-21 13:50:36 -02:00
parent b33f13600e
commit c0e196e575
1 changed files with 6 additions and 2 deletions

View File

@ -4,13 +4,13 @@ module SimpleForm
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
@ -22,6 +22,10 @@ module SimpleForm
def has_placeholder?
placeholder_present?
end
def string?
input_type == :string
end
end
end
end