Extract a private method to apply the label_input component options

This commit is contained in:
Rafael Mendonça França 2013-11-12 19:50:14 -02:00
parent 6f4e045d24
commit cd2f381154
1 changed files with 11 additions and 2 deletions

View File

@ -8,12 +8,21 @@ module SimpleForm
end
def label_input
apply_label_input_options(options)
options[:label] == false ? input : (label + input)
end
private
# Get the options given to the label_input component and apply to both
# label and input components.
def apply_label_input_options(options)
[:input_html, :label_html].each do |key|
if options.has_key? key
if options.has_key?(key)
options[key].merge! options.fetch(:label_input_html, {})
end
end
options[:label] == false ? input : (label + input)
end
end
end