Class: FoundationFormBuilder::Rails

Inherits:
ActionView::Helpers::FormBuilder
  • Object
show all
Defined in:
lib/foundation_form_builder/rails.rb

Instance Method Summary collapse

Instance Method Details

#input_div(field_name, label: nil, type: nil, values: nil, field: {}) ⇒ SafeBuffer

Renders a form field with label wrapped in an appropriate <div>, with another <div> for errors if necessary.

Raises:

  • (ArgumentError)

17
18
19
20
21
22
23
24
25
26
# File 'lib/foundation_form_builder/rails.rb', line 17

def input_div(field_name, label: nil, type: nil, values: nil, field: {})
  raise ArgumentError, ':values is only meaningful with type: :select' if values && type != :select
  @template. :div, class: field_name do
    [
      label(field_name, label),
      input_for(field_name, type, field, values: values),
      error_div(field_name)
    ].compact.join("\n").html_safe
  end
end