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 = {}, *args) ⇒ 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
- #radio_button(field, tag_value, options = {}) ⇒ Object
- #reverse_field(label_text, field, content, options = {}) ⇒ Object
- #submit(text) ⇒ Object
Instance Method Details
#array_from_classes(html_classes) ⇒ Object
78 79 80 |
# File 'lib/uberkit/forms/builder.rb', line 78 def array_from_classes(html_classes) html_classes ? html_classes.split(" ") : [] end |
#check_box(field, options = {}, *args) ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/uberkit/forms/builder.rb', line 50 def check_box(field, = {}, *args) label_text = .delete(:label) || field.to_s.titleize help = .delete(:help) required = .delete(:required) description = .delete(:description) title = .delete(:title) reverse_field(label_text, field, super(field, , *args), {:required => required, :help => help, :description => description, :title => title}) end |
#custom(options = {}, &block) ⇒ Object
72 73 74 75 76 |
# File 'lib/uberkit/forms/builder.rb', line 72 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
82 83 84 85 86 |
# File 'lib/uberkit/forms/builder.rb', line 82 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
96 |
# File 'lib/uberkit/forms/builder.rb', line 96 def is_haml?; false end |
#output_buffer ⇒ Object
88 89 90 |
# File 'lib/uberkit/forms/builder.rb', line 88 def output_buffer @template.output_buffer end |
#output_buffer=(buf) ⇒ Object
92 93 94 |
# File 'lib/uberkit/forms/builder.rb', line 92 def output_buffer=(buf) @template.output_buffer = buf end |
#radio_button(field, tag_value, options = {}) ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/uberkit/forms/builder.rb', line 59 def (field, tag_value, = {}) label_text = .delete(:label) || tag_value.to_s.titleize help = .delete(:help) required = .delete(:required) description = .delete(:description) title = .delete(:title) reverse_field(label_text, field, super(field, tag_value, ), {:required => required, :help => help, :description => description, :title => title} ) end |
#reverse_field(label_text, field, content, options = {}) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/uberkit/forms/builder.rb', line 32 def reverse_field(label_text, field, content, = {}) content_tag(:div, :class => "reverse_field#{' required' if [:required]}#{' labelless' if [:title].blank?}") do result = "" unless [:title].blank? result << content_tag(:span, [:title], :class => "pseudo_label") end result << content_tag(:div, :class => "pseudo_field") do ret = content 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 result end end |
#submit(text) ⇒ Object
68 69 70 |
# File 'lib/uberkit/forms/builder.rb', line 68 def submit(text) content_tag(:button, text, :type => "submit") end |