Module: Formtastic::Helpers::FormHelper

Defined in:
lib/page_record/formtastic.rb

Instance Method Summary collapse

Instance Method Details

#semantic_form_for(record_or_name_or_array, *args, &proc) ⇒ Object

This is a replacement method for the original semantic_form_for method from Formtastic. The only thing it does, is merge the form_record_for into the output.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/page_record/formtastic.rb', line 61

def semantic_form_for(record_or_name_or_array, *args, &proc)
  extend(PageRecord::Helpers)
  options = args.extract_options!
  options ||= {}
  case record_or_name_or_array
  when String, Symbol
    object_name = record_or_name_or_array
  else
    object      = record_or_name_or_array.is_a?(Array) ? record_or_name_or_array.last : record_or_name_or_array
    raise ArgumentError, 'First argument in form cannot contain nil or be empty' unless object
    object_name = options[:as] || model_name_from_record_or_class(object).param_key
  end
  options = options.merge(html: form_record_for(object_name))
  args << options
  semantic_form_for_org(record_or_name_or_array, *args, &proc)
end

#semantic_form_for_orgObject



55
# File 'lib/page_record/formtastic.rb', line 55

alias_method :semantic_form_for_org, :semantic_form_for