Class: Uberkit::Forms::Builder
- Inherits:
-
ActionView::Helpers::FormBuilder
- Object
- ActionView::Helpers::FormBuilder
- Uberkit::Forms::Builder
- Includes:
- ActionView::Helpers::CaptureHelper, ActionView::Helpers::TagHelper, ActionView::Helpers::TextHelper, ActionView::Helpers::UrlHelper
- Defined in:
- lib/uberkit/forms/builder.rb
Instance Method Summary collapse
- #array_from_classes(html_classes) ⇒ Object
- #check_box(field, options = {}, checked_value = "1", unchecked_value = "0") ⇒ Object
- #custom(options = {}, &block) ⇒ Object
- #fieldset(legend = nil, &block) ⇒ Object
- #generic_field(label_text, field, content, options = {}) ⇒ Object
- #is_haml? ⇒ Boolean
- #output_buffer ⇒ Object
- #output_buffer=(buf) ⇒ Object
- #submit(text) ⇒ Object
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, = {}, checked_value = "1", unchecked_value = "0") label_text = .delete(:label) || field.to_s.titleize help = .delete(:help) description = .delete(:description) content_tag(:div, :class => "check_box_row#{' require' if .delete(:required)}#{' labelless' if label_text.blank?}") do ret = super(field, , checked_value, unchecked_value) ret << label(field, label_text) ret << content_tag(:span, help, :class => 'help') unless help.blank? ret << content_tag(: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( = {}, &block) concat("<div class='field_row#{' labelless' unless [:label]}'>#{"<label#{" for='#{[:for]}'" if [:for]}>#{[:label] + ":" if [:label]}</label>" if [: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, = {}) required = .delete(:required) content_tag(: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 << content_tag(:span, .delete(:help), :class => "help") if [:help] ret << content_tag(:span, .delete(:description), :class => "description") if [:description] ret << "<br/>" ret end end |
#is_haml? ⇒ Boolean
75 |
# File 'lib/uberkit/forms/builder.rb', line 75 def is_haml?; false end |
#output_buffer ⇒ Object
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) content_tag(:button, text, :type => "submit") end |