Module: ActionView::Helpers::FormHelper

Defined in:
lib/context_help/patches/form_helper_patch.rb

Instance Method Summary collapse

Instance Method Details

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



54
55
56
57
58
# File 'lib/context_help/patches/form_helper_patch.rb', line 54

def check_box_with_context_help_check_box(object_name, method, options = {}, checked_value = "1", unchecked_value = "0")
  help_options = ContextHelp::Helpers.merge_options({:context_help => {:path => {:model => object_name.to_sym, :attribute=> method.to_sym}}}, options)
  help = ContextHelp::Base.help_for(help_options)
  check_box_without_context_help_check_box(object_name, method, options, checked_value, unchecked_value) + help
end

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



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/context_help/patches/form_helper_patch.rb', line 4

def fields_for_with_context_help_fields_for(record_or_name_or_array, *args, &block)
  case record_or_name_or_array
  when String, Symbol
    object_name = record_or_name_or_array
  else
    object_name = ActionController::RecordIdentifier.singular_class_name(record_or_name_or_array)
  end

  options = ContextHelp::Helpers.merge_options({:context_help => {:path => {:model => object_name.to_sym} } }, args.last.is_a?(::Hash)? args.last : {})
  help = ContextHelp::Base.help_for(options)
  help + fields_for_without_context_help_fields_for(record_or_name_or_array, *args, &block)
end

#file_field_with_context_help_file_field(object_name, method, options = {}) ⇒ Object



44
45
46
47
48
# File 'lib/context_help/patches/form_helper_patch.rb', line 44

def file_field_with_context_help_file_field(object_name, method, options = {})
  help_options = ContextHelp::Helpers.merge_options({:context_help => {:path => {:model => object_name.to_sym, :attribute=> method.to_sym}}}, options)
  help = ContextHelp::Base.help_for(help_options)
  file_field_without_context_help_file_field(object_name, method, options) + help
end

#hidden_field_with_context_help_hidden_field(object_name, method, options = {}) ⇒ Object



39
40
41
42
43
# File 'lib/context_help/patches/form_helper_patch.rb', line 39

def hidden_field_with_context_help_hidden_field(object_name, method, options = {})
  help_options = ContextHelp::Helpers.merge_options({:context_help => {:path => {:model => object_name.to_sym, :attribute=> method.to_sym}}}, options)
  help = ContextHelp::Base.help_for(help_options)
  hidden_field_without_context_help_hidden_field(object_name, method, options) + help
end

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



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/context_help/patches/form_helper_patch.rb', line 16

def label_with_context_help_label(object_name, method, text = nil, options = {})
  help_options = ContextHelp::Helpers.merge_options({:context_help => {:path => {:model => object_name.to_sym, :attribute=> method.to_sym}}}, options)
  ContextHelp::Base.help_for(help_options)
  link_to_help = ContextHelp::Base.link_to_help(help_options[:context_help])
  text = if text.blank?
    i18n_label = I18n.t("helpers.label.#{object_name}.#{method}", :default => "")
    i18n_label if i18n_label.present?
  else
    text.to_s
  end
  text ||= method.to_s.humanize
  label_without_context_help_label(object_name, method, text.to_s + link_to_help, help_options)
end

#password_field_with_context_help_password_field(object_name, method, options = {}) ⇒ Object



34
35
36
37
38
# File 'lib/context_help/patches/form_helper_patch.rb', line 34

def password_field_with_context_help_password_field(object_name, method, options = {})
  help_options = ContextHelp::Helpers.merge_options({:context_help => {:path => {:model => object_name.to_sym, :attribute=> method.to_sym}}}, options)
  help = ContextHelp::Base.help_for(help_options)
  password_field_without_context_help_password_field(object_name, method, options) + help
end

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



59
60
61
62
63
# File 'lib/context_help/patches/form_helper_patch.rb', line 59

def radio_button_with_context_help_radio_button(object_name, method, tag_value, options = {})
  help_options = ContextHelp::Helpers.merge_options({:context_help => {:path => {:model => object_name.to_sym, :attribute=> method.to_sym}}}, options)
  help = ContextHelp::Base.help_for(help_options)
  radio_button_without_context_help_radio_button(object_name, method, tag_value, options) +help
end

#text_area_with_context_help_text_area(object_name, method, options = {}) ⇒ Object



49
50
51
52
53
# File 'lib/context_help/patches/form_helper_patch.rb', line 49

def text_area_with_context_help_text_area(object_name, method, options = {})
  help_options = ContextHelp::Helpers.merge_options({:context_help => {:path => {:model => object_name.to_sym, :attribute=> method.to_sym}}}, options)
  help = ContextHelp::Base.help_for(help_options)
  text_area_without_context_help_text_area(object_name, method, options) + help
end

#text_field_with_context_help_text_field(object_name, method, options = {}) ⇒ Object



29
30
31
32
33
# File 'lib/context_help/patches/form_helper_patch.rb', line 29

def text_field_with_context_help_text_field(object_name, method, options = {})
  help_options = ContextHelp::Helpers.merge_options({:context_help => {:path => {:model => object_name.to_sym, :attribute=> method.to_sym}}}, options)
  help = ContextHelp::Base.help_for(help_options)
  text_field_without_context_help_text_field(object_name, method, options) + help
end