Class: ActionView::Helpers::FormBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/action_view/helpers/form_helper.rb,
lib/action_view/helpers/date_helper.rb,
lib/action_view/helpers/form_options_helper.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object_name, object, template, options, proc) ⇒ FormBuilder

Returns a new instance of FormBuilder.



701
702
703
704
# File 'lib/action_view/helpers/form_helper.rb', line 701

def initialize(object_name, object, template, options, proc)
  @object_name, @object, @template, @options, @proc = object_name, object, template, options, proc
  @default_options = @options ? @options.slice(:index) : {}
end

Instance Attribute Details

#objectObject

Returns the value of attribute object.



699
700
701
# File 'lib/action_view/helpers/form_helper.rb', line 699

def object
  @object
end

#object_nameObject

Returns the value of attribute object_name.



699
700
701
# File 'lib/action_view/helpers/form_helper.rb', line 699

def object_name
  @object_name
end

#optionsObject

Returns the value of attribute options.



699
700
701
# File 'lib/action_view/helpers/form_helper.rb', line 699

def options
  @options
end

Instance Method Details

#check_box(method, options = {}, checked_value = "1", unchecked_value = "0") ⇒ Object



736
737
738
# File 'lib/action_view/helpers/form_helper.rb', line 736

def check_box(method, options = {}, checked_value = "1", unchecked_value = "0")
  @template.check_box(@object_name, method, objectify_options(options), checked_value, unchecked_value)
end

#collection_select(method, collection, value_method, text_method, options = {}, html_options = {}) ⇒ Object



445
446
447
# File 'lib/action_view/helpers/form_options_helper.rb', line 445

def collection_select(method, collection, value_method, text_method, options = {}, html_options = {})
  @template.collection_select(@object_name, method, collection, value_method, text_method, options.merge(:object => @object), html_options)
end

#country_select(method, priority_countries = nil, options = {}, html_options = {}) ⇒ Object



449
450
451
# File 'lib/action_view/helpers/form_options_helper.rb', line 449

def country_select(method, priority_countries = nil, options = {}, html_options = {})
  @template.country_select(@object_name, method, priority_countries, options.merge(:object => @object), html_options)
end

#date_select(method, options = {}, html_options = {}) ⇒ Object



698
699
700
# File 'lib/action_view/helpers/date_helper.rb', line 698

def date_select(method, options = {}, html_options = {})
  @template.date_select(@object_name, method, options.merge(:object => @object), html_options)
end

#datetime_select(method, options = {}, html_options = {}) ⇒ Object



706
707
708
# File 'lib/action_view/helpers/date_helper.rb', line 706

def datetime_select(method, options = {}, html_options = {})
  @template.datetime_select(@object_name, method, options.merge(:object => @object), html_options)
end

#error_message_on(method, prepend_text = "", append_text = "", css_class = "formError") ⇒ Object



744
745
746
# File 'lib/action_view/helpers/form_helper.rb', line 744

def error_message_on(method, prepend_text = "", append_text = "", css_class = "formError")
  @template.error_message_on(@object, method, prepend_text, append_text, css_class)
end

#error_messages(options = {}) ⇒ Object



748
749
750
# File 'lib/action_view/helpers/form_helper.rb', line 748

def error_messages(options = {})
  @template.error_messages_for(@object_name, objectify_options(options))
end

#fields_for(record_or_name_or_array, *args, &block) ⇒ Object



715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
# File 'lib/action_view/helpers/form_helper.rb', line 715

def fields_for(record_or_name_or_array, *args, &block)
  case record_or_name_or_array
  when String, Symbol
    name = "#{object_name}[#{record_or_name_or_array}]"
  when Array
    object = record_or_name_or_array.last
    name = "#{object_name}[#{ActionController::RecordIdentifier.singular_class_name(object)}]"
    args.unshift(object)
  else
    object = record_or_name_or_array
    name = "#{object_name}[#{ActionController::RecordIdentifier.singular_class_name(object)}]"
    args.unshift(object)
  end

  @template.fields_for(name, *args, &block)
end

#label(method, text = nil, options = {}) ⇒ Object



732
733
734
# File 'lib/action_view/helpers/form_helper.rb', line 732

def label(method, text = nil, options = {})
  @template.label(@object_name, method, text, objectify_options(options))
end

#radio_button(method, tag_value, options = {}) ⇒ Object



740
741
742
# File 'lib/action_view/helpers/form_helper.rb', line 740

def radio_button(method, tag_value, options = {})
  @template.radio_button(@object_name, method, tag_value, objectify_options(options))
end

#select(method, choices, options = {}, html_options = {}) ⇒ Object



441
442
443
# File 'lib/action_view/helpers/form_options_helper.rb', line 441

def select(method, choices, options = {}, html_options = {})
  @template.select(@object_name, method, choices, options.merge(:object => @object), html_options)
end

#submit(value = "Save changes", options = {}) ⇒ Object



752
753
754
# File 'lib/action_view/helpers/form_helper.rb', line 752

def submit(value = "Save changes", options = {})
  @template.submit_tag(value, options.reverse_merge(:id => "#{object_name}_submit"))
end

#time_select(method, options = {}, html_options = {}) ⇒ Object



702
703
704
# File 'lib/action_view/helpers/date_helper.rb', line 702

def time_select(method, options = {}, html_options = {})
  @template.time_select(@object_name, method, options.merge(:object => @object), html_options)
end

#time_zone_select(method, priority_zones = nil, options = {}, html_options = {}) ⇒ Object



453
454
455
# File 'lib/action_view/helpers/form_options_helper.rb', line 453

def time_zone_select(method, priority_zones = nil, options = {}, html_options = {})
  @template.time_zone_select(@object_name, method, priority_zones, options.merge(:object => @object), html_options)
end