Extract a private method to apply the label_input component options
This commit is contained in:
parent
6f4e045d24
commit
cd2f381154
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue