Class: ActionView::Helpers::FormBuilder
- 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
-
#object ⇒ Object
Returns the value of attribute object.
-
#object_name ⇒ Object
Returns the value of attribute object_name.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #check_box(method, options = {}, checked_value = "1", unchecked_value = "0") ⇒ Object
- #collection_select(method, collection, value_method, text_method, options = {}, html_options = {}) ⇒ Object
- #country_select(method, priority_countries = nil, options = {}, html_options = {}) ⇒ Object
- #date_select(method, options = {}, html_options = {}) ⇒ Object
- #datetime_select(method, options = {}, html_options = {}) ⇒ Object
- #error_message_on(method, prepend_text = "", append_text = "", css_class = "formError") ⇒ Object
- #error_messages(options = {}) ⇒ Object
- #fields_for(record_or_name_or_array, *args, &block) ⇒ Object
-
#initialize(object_name, object, template, options, proc) ⇒ FormBuilder
constructor
A new instance of FormBuilder.
- #label(method, text = nil, options = {}) ⇒ Object
- #radio_button(method, tag_value, options = {}) ⇒ Object
- #select(method, choices, options = {}, html_options = {}) ⇒ Object
- #submit(value = "Save changes", options = {}) ⇒ Object
- #time_select(method, options = {}, html_options = {}) ⇒ Object
- #time_zone_select(method, priority_zones = nil, options = {}, html_options = {}) ⇒ Object
Constructor Details
#initialize(object_name, object, template, options, proc) ⇒ FormBuilder
Returns a new instance of FormBuilder.
697 698 699 700 |
# File 'lib/action_view/helpers/form_helper.rb', line 697 def initialize(object_name, object, template, , proc) @object_name, @object, @template, @options, @proc = object_name, object, template, , proc @default_options = @options ? @options.slice(:index) : {} end |
Instance Attribute Details
#object ⇒ Object
Returns the value of attribute object.
695 696 697 |
# File 'lib/action_view/helpers/form_helper.rb', line 695 def object @object end |
#object_name ⇒ Object
Returns the value of attribute object_name.
695 696 697 |
# File 'lib/action_view/helpers/form_helper.rb', line 695 def object_name @object_name end |
#options ⇒ Object
Returns the value of attribute options.
695 696 697 |
# File 'lib/action_view/helpers/form_helper.rb', line 695 def @options end |
Instance Method Details
#check_box(method, options = {}, checked_value = "1", unchecked_value = "0") ⇒ Object
732 733 734 |
# File 'lib/action_view/helpers/form_helper.rb', line 732 def check_box(method, = {}, checked_value = "1", unchecked_value = "0") @template.check_box(@object_name, method, (), checked_value, unchecked_value) end |
#collection_select(method, collection, value_method, text_method, options = {}, html_options = {}) ⇒ Object
444 445 446 |
# File 'lib/action_view/helpers/form_options_helper.rb', line 444 def collection_select(method, collection, value_method, text_method, = {}, = {}) @template.collection_select(@object_name, method, collection, value_method, text_method, .merge(:object => @object), ) end |
#country_select(method, priority_countries = nil, options = {}, html_options = {}) ⇒ Object
448 449 450 |
# File 'lib/action_view/helpers/form_options_helper.rb', line 448 def country_select(method, priority_countries = nil, = {}, = {}) @template.country_select(@object_name, method, priority_countries, .merge(:object => @object), ) 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, = {}, = {}) @template.date_select(@object_name, method, .merge(:object => @object)) 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, = {}, = {}) @template.datetime_select(@object_name, method, .merge(:object => @object)) end |
#error_message_on(method, prepend_text = "", append_text = "", css_class = "formError") ⇒ Object
740 741 742 |
# File 'lib/action_view/helpers/form_helper.rb', line 740 def (method, prepend_text = "", append_text = "", css_class = "formError") @template.(@object, method, prepend_text, append_text, css_class) end |
#error_messages(options = {}) ⇒ Object
744 745 746 |
# File 'lib/action_view/helpers/form_helper.rb', line 744 def ( = {}) @template.(@object_name, ()) end |
#fields_for(record_or_name_or_array, *args, &block) ⇒ Object
711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 |
# File 'lib/action_view/helpers/form_helper.rb', line 711 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
728 729 730 |
# File 'lib/action_view/helpers/form_helper.rb', line 728 def label(method, text = nil, = {}) @template.label(@object_name, method, text, ()) end |
#radio_button(method, tag_value, options = {}) ⇒ Object
736 737 738 |
# File 'lib/action_view/helpers/form_helper.rb', line 736 def (method, tag_value, = {}) @template.(@object_name, method, tag_value, ()) end |
#select(method, choices, options = {}, html_options = {}) ⇒ Object
440 441 442 |
# File 'lib/action_view/helpers/form_options_helper.rb', line 440 def select(method, choices, = {}, = {}) @template.select(@object_name, method, choices, .merge(:object => @object), ) end |
#submit(value = "Save changes", options = {}) ⇒ Object
748 749 750 |
# File 'lib/action_view/helpers/form_helper.rb', line 748 def submit(value = "Save changes", = {}) @template.submit_tag(value, .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, = {}, = {}) @template.time_select(@object_name, method, .merge(:object => @object)) end |
#time_zone_select(method, priority_zones = nil, options = {}, html_options = {}) ⇒ Object
452 453 454 |
# File 'lib/action_view/helpers/form_options_helper.rb', line 452 def time_zone_select(method, priority_zones = nil, = {}, = {}) @template.time_zone_select(@object_name, method, priority_zones, .merge(:object => @object), ) end |