Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MultiValueInput#collection is responsible for what to draw. #61

Merged
merged 1 commit into from
Jan 13, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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