Skip to content

Commit

Permalink
MultiValueInput#collection is responsible for what to draw.
Browse files Browse the repository at this point in the history
MultiValueInput#input is responsible for how to draw it.
  • Loading branch information
jcoyne committed Jan 13, 2015
1 parent 07c13e9 commit d88697a
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions app/inputs/multi_value_input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,14 @@ def input(wrapper_options)
HTML

collection.each do |value|
unless value.to_s.strip.blank?
markup << <<-HTML
<li class="field-wrapper">
#{build_text_field(value)}
</li>
HTML
end
markup << <<-HTML
<li class="field-wrapper">
#{build_text_field(value)}
</li>
HTML
end

# One blank line at the end
markup << <<-HTML
<li class="field-wrapper">
#{build_text_field('')}
</li>
</ul>
HTML
Expand Down Expand Up @@ -61,7 +55,7 @@ def input_dom_id
end

def collection
@collection ||= Array.wrap(object[attribute_name])
@collection ||= Array.wrap(object[attribute_name]).reject { |value| value.to_s.strip.blank? } + ['']
end

def multiple?; true; end
Expand Down

0 comments on commit d88697a

Please sign in to comment.