Class: ForgeFormBuilder

Inherits:
ActionView::Helpers::FormBuilder
  • Object
show all
Includes:
ActionView::Helpers::TagHelper, Ckeditor::Helpers::FormBuilder
Defined in:
lib/forge/app/form_builders/forge_form_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#output_bufferObject

Returns the value of attribute output_buffer.



4
5
6
# File 'lib/forge/app/form_builders/forge_form_builder.rb', line 4

def output_buffer
  @output_buffer
end

Instance Method Details

#cktext_area(method_name, options = {}) ⇒ Object



20
21
22
# File 'lib/forge/app/form_builders/forge_form_builder.rb', line 20

def cktext_area(method_name, options = {})
  content = build_content(:cktext_area_content, method_name, options)
end

#cktext_area_content(method_name, options = {}, language = nil, language_title = nil) ⇒ Object



24
25
26
27
28
# File 'lib/forge/app/form_builders/forge_form_builder.rb', line 24

def cktext_area_content(method_name, options = {}, language = nil, language_title = nil)
  label = label(method_name, options[:label], language, language_title)
  explanation = explanation(options[:explanation])
  label + explanation + super_cktext_area(get_method(method_name, language), options)
end

#datetime_widget(method_name, options = {}) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/forge/app/form_builders/forge_form_builder.rb', line 52

def datetime_widget(method_name, options = {})
  label = label(method_name, options[:label], nil, nil)
  explanation = explanation(options[:explanation])

  on = (:tr) do
    [
      (:td, "On: "),
      (:td, super_text_field("#{method_name}_date", :class => "datepicker", :size => 12, :value => @object.send(method_name) ? @object.send(method_name).strftime('%Y-%m-%d') : (options[:default_date] || Time.now.strftime('%Y-%m-%d'))))
    ].join("\n").html_safe
  end
  at = (:tr) do
    [
      (:td, "At: "),
      (:td, super_text_field("#{method_name}_time", :value => @object.send(method_name) ? @object.send(method_name).strftime('%l:%M%p').strip : (options[:default_time] || Time.now.strftime('%l:%M%p').strip), :size => 7))
    ].join("\n").html_safe
  end
  table = (:table, on + at, :class => 'datetime_select')

  content = label(method_name, options[:label], nil, nil)
  content += explanation(options[:explanation])
  content += (:div, table, :class => 'inset datetime-widget')
  content +=  :hr unless options[:last]
end

#super_cktext_areaObject



19
# File 'lib/forge/app/form_builders/forge_form_builder.rb', line 19

alias :super_cktext_area :cktext_area

#super_labelObject



5
# File 'lib/forge/app/form_builders/forge_form_builder.rb', line 5

alias :super_label :label

#super_text_areaObject



41
# File 'lib/forge/app/form_builders/forge_form_builder.rb', line 41

alias :super_text_area :text_area

#super_text_fieldObject



30
# File 'lib/forge/app/form_builders/forge_form_builder.rb', line 30

alias :super_text_field :text_field

#text_area(method_name, options = {}) ⇒ Object



42
43
44
# File 'lib/forge/app/form_builders/forge_form_builder.rb', line 42

def text_area(method_name, options = {})
  content = build_content(:text_area_content, method_name, options)
end

#text_area_content(method_name, options = {}, language = nil, language_title = nil) ⇒ Object



46
47
48
49
50
# File 'lib/forge/app/form_builders/forge_form_builder.rb', line 46

def text_area_content(method_name, options = {}, language = nil, language_title = nil)
  label = label(method_name, options[:label], language, language_title)
  explanation = explanation(options[:explanation])
  label + explanation + super_text_area(get_method(method_name, language), options)
end

#text_field(method_name, options = {}) ⇒ Object



31
32
33
# File 'lib/forge/app/form_builders/forge_form_builder.rb', line 31

def text_field(method_name, options = {})
  content = build_content(:text_field_content, method_name, options)
end

#text_field_content(method_name, options = {}, language = nil, language_title = nil) ⇒ Object



35
36
37
38
39
# File 'lib/forge/app/form_builders/forge_form_builder.rb', line 35

def text_field_content(method_name, options = {}, language = nil, language_title = nil)
  label = label(method_name, options[:label], language, language_title)
  explanation = explanation(options[:explanation])
  label + explanation + super_text_field(get_method(method_name, language), options)
end

#title_field(method_name, options = {}) ⇒ Object



7
8
9
10
# File 'lib/forge/app/form_builders/forge_form_builder.rb', line 7

def title_field(method_name, options = {})
  options[:last] = true
  content = build_content(:title_field_content, method_name, options)
end

#title_field_content(method_name, options = {}, language = nil, language_title = nil) ⇒ Object



12
13
14
15
16
17
# File 'lib/forge/app/form_builders/forge_form_builder.rb', line 12

def title_field_content(method_name, options = {}, language = nil, language_title = nil)
  label = label(method_name, options[:label], language, language_title)
  explanation = explanation(options[:explanation])
  row_label = (:div, label + explanation, :class => "label")
  row_label.html_safe + @template.text_field(@object_name, get_method(method_name, language), options.merge({:class => "title"})) + (:div, "", :class => "spacer")
end