Module: Forma::FieldHelper

Included in:
Col, ComplexField, Form, SubformField, Tab, Table
Defined in:
lib/forma/helpers.rb

Instance Method Summary collapse

Instance Method Details

#array_field(name, opts = {}) {|field| ... } ⇒ Object

Yields:

  • (field)


124
125
126
127
128
129
# File 'lib/forma/helpers.rb', line 124

def array_field(name, opts = {})
  opts[:name] = name
  field = Forma::ArrayField.new(opts)
  yield field if block_given?
  add_field(field)
end

#boolean_field(name, opts = {}) {|field| ... } ⇒ Object

Yields:

  • (field)


81
82
83
84
85
86
# File 'lib/forma/helpers.rb', line 81

def boolean_field(name, opts={})
  opts[:name] = name
  field = Forma::BooleanField.new(opts)
  yield field if block_given?
  add_field(field)
end

#combo_field(name, opts = {}) {|field| ... } ⇒ Object

Yields:

  • (field)


109
110
111
112
113
114
# File 'lib/forma/helpers.rb', line 109

def combo_field(name, opts = {})
  opts[:name] = name
  field = Forma::ComboField.new(opts)
  yield field if block_given?
  add_field(field)
end

#complex_field(opts = {}) {|field| ... } ⇒ Object

Yields:

  • (field)


35
36
37
38
39
# File 'lib/forma/helpers.rb', line 35

def complex_field(opts = {})
  field = Forma::ComplexField.new(opts)
  yield field if block_given?
  add_field(field)
end

#date_field(name, opts = {}) {|field| ... } ⇒ Object

Yields:

  • (field)


74
75
76
77
78
79
# File 'lib/forma/helpers.rb', line 74

def date_field(name, opts={})
  opts[:name] = name
  field = Forma::DateField.new(opts)
  yield field if block_given?
  add_field(field)
end

#email_field(name, opts = {}) {|field| ... } ⇒ Object

Yields:

  • (field)


67
68
69
70
71
72
# File 'lib/forma/helpers.rb', line 67

def email_field(name, opts={})
  opts[:name] = name
  field = Forma::EmailField.new(opts)
  yield field if block_given?
  add_field(field)
end

#file_field(name, opts = {}) {|field| ... } ⇒ Object

Yields:

  • (field)


95
96
97
98
99
100
# File 'lib/forma/helpers.rb', line 95

def file_field(name, opts={})
  opts[:name] = name
  field = Forma::FileField.new(opts)
  yield field if block_given?
  add_field(field)
end

#image_field(name, opts = {}) {|field| ... } ⇒ Object

Yields:

  • (field)


88
89
90
91
92
93
# File 'lib/forma/helpers.rb', line 88

def image_field(name, opts={})
  opts[:name] = name
  field = Forma::ImageField.new(opts)
  yield field if block_given?
  add_field(field)
end

#map_field(name, opts = {}) {|field| ... } ⇒ Object

Yields:

  • (field)


41
42
43
44
45
46
# File 'lib/forma/helpers.rb', line 41

def map_field(name, opts = {})
  opts[:name] = name
  field = Forma::MapField.new(opts)
  yield field if block_given?
  add_field(field)
end

#number_field(name, opts = {}) {|field| ... } ⇒ Object

Yields:

  • (field)


102
103
104
105
106
107
# File 'lib/forma/helpers.rb', line 102

def number_field(name, opts = {})
  opts[:name] = name
  field = Forma::NumberField.new(opts)
  yield field if block_given?
  add_field(field)
end

#password_field(name, opts = {}) ⇒ Object



62
63
64
65
# File 'lib/forma/helpers.rb', line 62

def password_field(name, opts={})
  opts[:password] = true
  text_field(name, opts)
end

#select_field(name, search_url, opts = {}) {|field| ... } ⇒ Object

Yields:

  • (field)


116
117
118
119
120
121
122
# File 'lib/forma/helpers.rb', line 116

def select_field(name, search_url, opts = {})
  opts[:name] = name
  opts[:search_url] = search_url
  field = Forma::SelectField.new(opts)
  yield field if block_given?
  add_field(field)
end

#subform(name, opts = {}) {|field.form| ... } ⇒ Object

Yields:

  • (field.form)


48
49
50
51
52
53
# File 'lib/forma/helpers.rb', line 48

def subform(name, opts = {})
  opts[:name] = name
  field = Forma::SubformField.new(opts)
  yield field.form if block_given?
  add_field(field)
end

#table_field(name, opts = {}) {|field| ... } ⇒ Object

Yields:

  • (field)


131
132
133
134
135
136
# File 'lib/forma/helpers.rb', line 131

def table_field(name, opts = {})
  opts[:name] = name
  field = Forma::TableField.new(opts)
  yield field if block_given?
  add_field(field)
end

#text_field(name, opts = {}) {|field| ... } ⇒ Object

Yields:

  • (field)


55
56
57
58
59
60
# File 'lib/forma/helpers.rb', line 55

def text_field(name, opts={})
  opts[:name] = name
  field = Forma::TextField.new(opts)
  yield field if block_given?
  add_field(field)
end