Class: ContextHelp::SemanticFormBuilder

Inherits:
Formtastic::SemanticFormBuilder
  • Object
show all
Defined in:
lib/context_help/patches/formtastic_patch.rb

Instance Method Summary collapse

Instance Method Details

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



13
14
15
16
17
18
19
20
# File 'lib/context_help/patches/formtastic_patch.rb', line 13

def input(method, options = {})   
  options = ContextHelp::Helpers.merge_options({:context_help => {:path => {:model => model_name.to_sym, :attribute=> method.to_sym}}}, options || {})
  options[:label_html] ||= {}
  options[:label_html][:context_help] = options[:context_help].dup
  options[:input_html] ||= {}
  options[:input_html][:context_help] = options[:context_help].dup
  super method, options
end

#inputs(*args, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/context_help/patches/formtastic_patch.rb', line 3

def inputs(*args, &block)
  title = field_set_title_from_args(*args)
  html_options = args.extract_options!

  help_options = ContextHelp::Helpers.merge_options({:context_help => {:path => {:tag => 'fieldset', :tag_options => html_options}}}, html_options)
  help_options[:context_help][:title] = title if help_options[:context_help][:path][:tag]

  help = ContextHelp::Base.help_for(help_options)
  super *(args<<help_options), &block
end

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



26
27
28
29
30
31
32
33
34
35
# File 'lib/context_help/patches/formtastic_patch.rb', line 26

def legend_tag(method, options = {})
  if options[:label] == false
    Formtastic::Util.html_safe("")
  else
    text = localized_string(method, options[:label], :label) || humanized_attribute_name(method)
    text += required_or_optional_string(options.delete(:required))
    text = Formtastic::Util.html_safe(text)
    template. :legend, template.label_tag(nil, text, options), :class => :label
  end
end

#radio_input(method, options) ⇒ Object



21
22
23
24
25
# File 'lib/context_help/patches/formtastic_patch.rb', line 21

def radio_input(method, options)
  options[:label] = localized_string(method, options[:label], :label) || humanized_attribute_name(method)
  ContextHelp::Base.help_for(options) 
  super method, options
end