Module: FlexaFormtasticBootstrap::Helpers::InputsHelper

Includes:
FieldsetWrapper
Included in:
FormBuilder
Defined in:
lib/flexa_formtastic_bootstrap/helpers/inputs_helper.rb

Instance Method Summary collapse

Instance Method Details

#inputs(*args, &block) ⇒ Object



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
32
# File 'lib/flexa_formtastic_bootstrap/helpers/inputs_helper.rb', line 6

def inputs(*args, &block)
  wrap_it = @already_in_an_inputs_block ? true : false
  @already_in_an_inputs_block = true

  title = field_set_title_from_args(*args)
  html_options = args.extract_options!
  html_options[:class] ||= "inputs"
  html_options[:name] = title

  out = begin
    if html_options[:for] # Nested form
      inputs_for_nested_attributes(*(args << html_options), &block)
    elsif block_given?
      field_set_and_list_wrapping(*(args << html_options), &block)
    else
      legend = args.shift if args.first.is_a?(::String)
      args = default_columns_for_object if @object && args.empty?
      contents = fieldset_contents_from_column_list(args)
      args.unshift(legend) if legend.present?
      field_set_and_list_wrapping(*((args << html_options) << contents))
    end
  end

  # out = template.content_tag(:li, out, :class => "input") if wrap_it
  @already_in_an_inputs_block = false
  out
end