Class: Kiss::Form::Column
Instance Method Summary collapse
-
#component_table_row_html(field) ⇒ Object
Renders HTML for specified form field.
-
#components_html ⇒ Object
(also: #fields_html)
Renders HTML for form fields.
- #html ⇒ Object
-
#initialize(form = nil) ⇒ Column
constructor
A new instance of Column.
-
#table_closing_html ⇒ Object
(also: #table_html_close)
Renders close of form table.
-
#table_opening_html ⇒ Object
(also: #table_html_open)
Renders open of form table.
Constructor Details
#initialize(form = nil) ⇒ Column
Returns a new instance of Column.
41 42 43 44 |
# File 'lib/kiss/form.rb', line 41 def initialize(form = nil) @_form = form @_components = [] end |
Instance Method Details
#component_table_row_html(field) ⇒ Object
Renders HTML for specified form field.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/kiss/form.rb', line 47 def component_table_row_html(field) field = fields[field.to_s] if (field.is_a?(Symbol) || field.is_a?(String)) return field.element_html if field.is_a?(HiddenField) type = field.class.type prompt = field.prompt label = field.label errors = field.errors_html required = field.required ? %Q(<span class="kiss_form_required">#{@_form.mark_required}</span> ) : '' parts = [ prompt ? %Q(<tr class="kiss_form_prompt"><td class="kiss_form_label">#{required}</td><td>#{prompt.to_s}</td></tr>) : '', %Q(<tr class="kiss_form_#{type}"><td class="kiss_form_label#{errors ? ' error' : ''}">), !prompt ? (required + (label.blank? ? '' : label.to_s + ':' )) : '', %Q(</td><td class="kiss_form_#{type}">), field.element_html, "</td></tr>" ] if errors parts += [ '<tr class="kiss_form_error_row"><td class="kiss_form_required"></td><td>', errors, '</td></tr>' ] end parts.join end |
#components_html ⇒ Object Also known as: fields_html
Renders HTML for form fields.
75 76 77 78 79 |
# File 'lib/kiss/form.rb', line 75 def components_html @_components.map do |component| component_table_row_html(component) end.join end |
#html ⇒ Object
94 95 96 97 98 99 100 101 102 |
# File 'lib/kiss/form.rb', line 94 def html [ '<td class="kiss_form_column">', table_html_open, components_html, table_html_close, '</td>' ].join end |
#table_closing_html ⇒ Object Also known as: table_html_close
Renders close of form table.
89 90 91 |
# File 'lib/kiss/form.rb', line 89 def table_closing_html '</tbody></table>' end |
#table_opening_html ⇒ Object Also known as: table_html_open
Renders open of form table.
83 84 85 |
# File 'lib/kiss/form.rb', line 83 def table_opening_html %Q(<table class="kiss_form_column" border=0 cellspacing=0><tbody>) end |