Class: Formtastic::Inputs::ArrayInput

Inherits:
Object
  • Object
show all
Includes:
Base, Formtastic::InputHelpers
Defined in:
lib/formtastic/inputs/array_input.rb

Instance Method Summary collapse

Methods included from Formtastic::InputHelpers

#ci_hidden_field, #ci_text_field, #icon_tag, #input_classes

Instance Method Details

#to_htmlObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/formtastic/inputs/array_input.rb', line 7

def to_html
  @undoable = options[:undoable]
  input_wrapping do
    inputs = []

    values = @object.send(method)
    if values
      values.each_with_index do |v, x|
        inputs << array_input_html(v)
      end
    end

    label_html <<
        template.(:div, class: 'input-group--array') do
          inputs.join.html_safe <<
              array_input_html('', false) <<
              array_input_html('', true, true) # template for creating new array input field
        end
  end
end