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.



629
630
631
# File 'lib/action_view/helpers/form_helper.rb', line 629

def initialize(object_name, object, template, options, proc)
  @object_name, @object, @template, @options, @proc = object_name, object, template, options, proc
end

Instance Attribute Details

#objectObject

Returns the value of attribute object.



627
628
629
# File 'lib/action_view/helpers/form_helper.rb', line 627

def object
  @object
end

#object_nameObject

Returns the value of attribute object_name.



627
628
629
# File 'lib/action_view/helpers/form_helper.rb', line 627

def object_name
  @object_name
end

#optionsObject

Returns the value of attribute options.



627
628
629
# File 'lib/action_view/helpers/form_helper.rb', line 627

def options
  @options
end

Instance Method Details

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



663
664
665
# File 'lib/action_view/helpers/form_helper.rb', line 663

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

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



412
413
414
# File 'lib/action_view/helpers/form_options_helper.rb', line 412

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



416
417
418
# File 'lib/action_view/helpers/form_options_helper.rb', line 416

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 = {}) ⇒ Object



676
677
678
# File 'lib/action_view/helpers/date_helper.rb', line 676

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

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



684
685
686
# File 'lib/action_view/helpers/date_helper.rb', line 684

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

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



671
672
673
# File 'lib/action_view/helpers/form_helper.rb', line 671

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



675
676
677
# File 'lib/action_view/helpers/form_helper.rb', line 675

def error_messages(options = {})
  @template.error_messages_for(@object_name, options.merge(:object => @object))
end

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



642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
# File 'lib/action_view/helpers/form_helper.rb', line 642

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



659
660
661
# File 'lib/action_view/helpers/form_helper.rb', line 659

def label(method, text = nil, options = {})
  @template.label(@object_name, method, text, options.merge(:object => @object))
end

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



667
668
669
# File 'lib/action_view/helpers/form_helper.rb', line 667

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

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



408
409
410
# File 'lib/action_view/helpers/form_options_helper.rb', line 408

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



679
680
681
# File 'lib/action_view/helpers/form_helper.rb', line 679

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

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



680
681
682
# File 'lib/action_view/helpers/date_helper.rb', line 680

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

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



420
421
422
# File 'lib/action_view/helpers/form_options_helper.rb', line 420

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