Class: VertForm

Inherits:
Object
  • Object
show all
Defined in:
lib/vertform.rb,
lib/vertform/version.rb

Constant Summary collapse

VERSION =

:nodoc:

"0.0.6"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(form_fields = {}) ⇒ VertForm

Returns a new instance of VertForm.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/vertform.rb', line 6

def initialize(form_fields = {})
	@table_params = {
		"class" => "table vf-table"
	}
	@td_label_params = {
		"class" => "vf-td vf-td-left",
		"style" => "width: 32%;"
	}
	@label_params = {
		"class" => "pull-right vf-labels",
		"style" => "margin-top: 4px;"
	}
	@td_input_params = {
		"class" => "vf-td vf-td-right",
		"style" => "width: 68%;"
	}
	@form_fields = form_fields
end

Instance Attribute Details

#form_fieldsObject

Returns the value of attribute form_fields.



4
5
6
# File 'lib/vertform.rb', line 4

def form_fields
  @form_fields
end

#label_paramsObject

Returns the value of attribute label_params.



4
5
6
# File 'lib/vertform.rb', line 4

def label_params
  @label_params
end

#table_paramsObject

Returns the value of attribute table_params.



4
5
6
# File 'lib/vertform.rb', line 4

def table_params
  @table_params
end

Instance Method Details

#rend_form(form_fields = @form_fields) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/vertform.rb', line 25

def rend_form(form_fields = @form_fields)
	out_string = ""
	out_string .
	concat "<table " .
	concat pair_json(@table_params) .
	concat ">\n"
	form_fields.each { |label,field|
		out_string .
		concat "  <tr>\n    <td " .
		concat pair_json(@td_label_params) .
		concat ">\n      " .
		concat "<span " .
		concat pair_json(@label_params) .
		concat ">\n        " .
		concat(label) .
		concat "\n      </span>\n    </td>\n    <td " .
		concat pair_json(@td_input_params) .
		concat ">\n      <%= " .
		concat(field) .
		concat " %>\n    </td>\n  </tr>\n"
	}
	out_string . concat "</table>"
end