Class: TableFormBuilder::Builder
- Inherits:
-
ActionView::Helpers::FormBuilder
- Object
- ActionView::Helpers::FormBuilder
- TableFormBuilder::Builder
- Defined in:
- lib/table_form_builder/builder.rb
Instance Method Summary collapse
- #actions(&block) ⇒ Object
- #check_box(field, *args) ⇒ Object
- #generate_error_message(field, error) ⇒ Object
- #generate_errors(field) ⇒ Object
- #group(text, &block) ⇒ Object
- #title(text) ⇒ Object
Instance Method Details
#actions(&block) ⇒ Object
39 40 41 42 43 |
# File 'lib/table_form_builder/builder.rb', line 39 def actions(&block) @template.content_tag(:tr) do @template.content_tag(:th) + @template.content_tag(:td, @template.capture(&block)) end end |
#check_box(field, *args) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/table_form_builder/builder.rb', line 16 def check_box(field, *args) = args.last.is_a?(Hash) ? args.pop : {} label = label(field, [:label]) extra = [:extra].nil? ? "" : @template.content_tag(:span, :class => "extra") { [:extra] } @template.content_tag(:tr) do @template.content_tag(:th) + @template.content_tag(:td, super(field, *args) + label + extra) end end |
#generate_error_message(field, error) ⇒ Object
49 50 51 |
# File 'lib/table_form_builder/builder.rb', line 49 def (field, error) "#{field.to_s.humanize} #{error}" end |
#generate_errors(field) ⇒ Object
45 46 47 |
# File 'lib/table_form_builder/builder.rb', line 45 def generate_errors(field) @object.errors[field].collect{|e| @template.content_tag(:div, :class => "error"){(field, e)}}.join.html_safe end |
#group(text, &block) ⇒ Object
25 26 27 28 29 |
# File 'lib/table_form_builder/builder.rb', line 25 def group(text, &block) @template.content_tag(:tr) do @template.content_tag(:th, text) + @template.content_tag(:td, @template.capture(&block)) end end |
#title(text) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/table_form_builder/builder.rb', line 31 def title(text) @template.content_tag(:tr) do @template.content_tag(:th) + @template.content_tag(:td) do @template.content_tag(:h3, text) end end end |