Class: ActionView::Helpers::FormBuilder

Inherits:
Object
  • Object
show all
Extended by:
HotDateRails::Utils
Includes:
FormTagHelper
Defined in:
app/helpers/form_helper.rb

Instance Method Summary collapse

Methods included from HotDateRails::Utils

deprecate

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object

handle type-specific calls (to :date_picker, :time_picker and :datetime_picker)



25
26
27
28
29
30
# File 'app/helpers/form_helper.rb', line 25

def method_missing(method, *args)
	cls = $1 if method =~ /(.*)_picker/
	return super unless cls #not a valid picker method call
	args = (args + Array.new(3)).slice(0..2).push("#{cls}picker") #pad args to 3 and add cls attr to end
	send(:hd_picker, *args)
end

Instance Method Details

#hd_label(name = nil, content_or_options = nil, options = nil, &block) ⇒ Object



42
43
44
# File 'app/helpers/form_helper.rb', line 42

def hd_label(name = nil, content_or_options = nil, options = nil, &block)
	label_tag name, content_or_options, options, &block
end

#hd_picker(attr, opts = nil, locale_format = nil, cls = nil) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'app/helpers/form_helper.rb', line 32

def hd_picker(attr, opts=nil, locale_format=nil, cls=nil)
	opts ||= {}
	col_type = column_type(attr)
	#Picker css class...if not explicitly specified get it from the type
	cls ||= col_type.to_s + "picker" 
	#need to specify datetime in locale file because rails thinks datetime is time
	locale_format ||= :datetime if col_type == :datetime
	draw_ext_input(attr, cls, locale_format, opts)
end