Class: Uberkit::Forms::Builder

Inherits:
ActionView::Helpers::FormBuilder
  • Object
show all
Includes:
ActionView::Helpers::CaptureHelper, ActionView::Helpers::TagHelper, ActionView::Helpers::TextHelper, ActionView::Helpers::UrlHelper
Defined in:
lib/uberkit/forms/builder.rb

Instance Method Summary collapse

Instance Method Details

#array_from_classes(html_classes) ⇒ Object



57
58
59
# File 'lib/uberkit/forms/builder.rb', line 57

def array_from_classes(html_classes)
  html_classes ? html_classes.split(" ") : []
end

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



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/uberkit/forms/builder.rb', line 32

def check_box(field, options = {}, checked_value = "1", unchecked_value = "0")
  label_text = options.delete(:label) || field.to_s.titleize
  help = options.delete(:help)
  description = options.delete(:description)

  (:div, :class => "check_box_row#{' require' if options.delete(:required)}#{' labelless' if label_text.blank?}") do
    ret = super(field, options, checked_value, unchecked_value)
    ret << label(field, label_text)
    ret << (:span, help, :class => 'help') unless help.blank?
    ret << (:span, description, :class => 'description') unless description.blank?
    ret << "<br/>"
    ret
  end
end

#custom(options = {}, &block) ⇒ Object



51
52
53
54
55
# File 'lib/uberkit/forms/builder.rb', line 51

def custom(options = {}, &block)
  concat("<div class='field_row#{' labelless' unless options[:label]}'>#{"<label#{" for='#{options[:for]}'" if options[:for]}>#{options[:label] + ":" if options[:label]}</label>" if options[:label]}<div class='pseudo_field'>",block.binding)
  yield
  concat("</div> <br/></div>",block.binding)
end

#fieldset(legend = nil, &block) ⇒ Object



61
62
63
64
65
# File 'lib/uberkit/forms/builder.rb', line 61

def fieldset(legend=nil,&block)
  concat("<fieldset>#{"<legend>#{legend}</legend>" if legend}")
  yield
  concat("</fieldset>")
end

#generic_field(label_text, field, content, options = {}) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/uberkit/forms/builder.rb', line 20

def generic_field(label_text,field,content,options = {})
  required = options.delete(:required)
  (:div, :class => "field_row#{' required' if required}#{' labelless' if label_text == ""}") do
    ret = label(field, (label_text || field.to_s.titleize).to_s + ":") unless label_text == ""
    ret << content
    ret << (:span, options.delete(:help), :class => "help") if options[:help]
    ret << (:span, options.delete(:description), :class => "description") if options[:description]
    ret << "<br/>"
    ret
  end
end

#is_haml?Boolean

Returns:

  • (Boolean)


75
# File 'lib/uberkit/forms/builder.rb', line 75

def is_haml?; false end

#output_bufferObject



67
68
69
# File 'lib/uberkit/forms/builder.rb', line 67

def output_buffer
  @template.output_buffer
end

#output_buffer=(buf) ⇒ Object



71
72
73
# File 'lib/uberkit/forms/builder.rb', line 71

def output_buffer=(buf)
  @template.output_buffer = buf
end

#submit(text) ⇒ Object



47
48
49
# File 'lib/uberkit/forms/builder.rb', line 47

def submit(text)
  (:button, text, :type => "submit")
end