Skip to content

Commit

Permalink
Extract a private method to apply the label_input component options
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelfranca authored and butsjoh committed Nov 28, 2013
1 parent e68979c commit 1d316fd
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/simple_form/components/label_input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,21 @@ module LabelInput
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
Expand Down

0 comments on commit 1d316fd

Please sign in to comment.