Skip to content

Commit

Permalink
Merge pull request #61 from projecthydra-labs/refactor_input
Browse files Browse the repository at this point in the history
MultiValueInput#collection is responsible for what to draw.
  • Loading branch information
Trey Terrell committed Jan 13, 2015
2 parents 1cfd521 + d88697a commit b69fa13
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 b69fa13

Please sign in to comment.