mirror of
https://github.com/heartcombo/simple_form.git
synced 2022-11-09 12:19:26 -05:00
Move 'input_method' to Base, map 'text_field' and 'password_field' in 'StringInput'
This commit is contained in:
parent
7121f3f2b6
commit
cb1c8ffa57
3 changed files with 11 additions and 6 deletions
|
@ -189,6 +189,11 @@ module SimpleForm
|
|||
action = action.to_sym
|
||||
ACTIONS[action] || action
|
||||
end
|
||||
|
||||
def input_method
|
||||
self.class.mappings[input_type] or
|
||||
raise("Could not find method for #{input_type.inspect}")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,11 +13,6 @@ module SimpleForm
|
|||
|
||||
private
|
||||
|
||||
def input_method
|
||||
self.class.mappings[input_type] or
|
||||
raise("Could not find method for #{input_type.inspect}")
|
||||
end
|
||||
|
||||
def has_placeholder?
|
||||
(text? || password?) && placeholder_present?
|
||||
end
|
||||
|
|
|
@ -1,12 +1,17 @@
|
|||
module SimpleForm
|
||||
module Inputs
|
||||
class StringInput < Base
|
||||
extend MapType
|
||||
|
||||
map_type :string, :email, :search, :tel, :url, :to => :text_field
|
||||
map_type :password, :to => :password_field
|
||||
|
||||
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 string?
|
||||
|
||||
@builder.text_field(attribute_name, input_html_options)
|
||||
@builder.send(input_method, attribute_name, input_html_options)
|
||||
end
|
||||
|
||||
def input_html_classes
|
||||
|
|
Loading…
Reference in a new issue