Class: MultiValueInput

Inherits:
SimpleForm::Inputs::CollectionInput
  • Object
show all
Defined in:
app/inputs/multi_value_input.rb

Instance Method Summary collapse

Instance Method Details

#inputObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/inputs/multi_value_input.rb', line 3

def input
  @rendered_first_element = false
  input_html_classes.unshift("string")
  input_html_options[:type] ||= 'text'
  input_html_options[:name] ||= "#{object_name}[#{attribute_name}][]"
  markup = <<-HTML


      <ul class="listing">
  HTML

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

  markup << <<-HTML
        <li class="field-wrapper">
          #{build_text_field('')}
        </li>
      </ul>

  HTML
end