Class: KirguduBase::DynamicPages::FormBuilder
Instance Method Summary
collapse
#css_class, #enabled, #html_options, #id, #visible
Constructor Details
#initialize(name, &block) ⇒ FormBuilder
Returns a new instance of FormBuilder.
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'app/models/kirgudu_base/dynamic_pages/form_builder.rb', line 4
def initialize(name, &block)
self.builder_options.merge!({
url: nil,
http_method: nil,
allow_client_validations: nil,
is_ajax: nil,
properties: nil,
elements: nil,
parent: nil
})
super(name, &block)
end
|
Instance Method Details
#allow_client_validations(value) ⇒ Object
35
36
37
|
# File 'app/models/kirgudu_base/dynamic_pages/form_builder.rb', line 35
def allow_client_validations(value)
self.builder_options[:allow_client_validations] = value
end
|
#elements ⇒ Object
51
52
53
54
55
56
57
|
# File 'app/models/kirgudu_base/dynamic_pages/form_builder.rb', line 51
def elements
elements = ::KirguduBase::DynamicPages::FormElementsBlockBuilder.new(&block).to_elements
elements.each do |element|
self.builder_options[:elements] = [] unless self.builder_options[:elements]
self.builder_options[:elements] << element
end
end
|
#http_method(value) ⇒ Object
31
32
33
|
# File 'app/models/kirgudu_base/dynamic_pages/form_builder.rb', line 31
def http_method(value)
self.builder_options[:http_method] = value
end
|
#is_ajax(value) ⇒ Object
39
40
41
|
# File 'app/models/kirgudu_base/dynamic_pages/form_builder.rb', line 39
def is_ajax(value)
self.builder_options[:is_ajax] = value
end
|
#parent(value) ⇒ Object
59
60
61
62
|
# File 'app/models/kirgudu_base/dynamic_pages/form_builder.rb', line 59
def parent(value)
self.validate_empty_parameter('parent', value)
self.builder_options[:parent] = value
end
|
#properties(&block) ⇒ Object
43
44
45
46
47
48
49
|
# File 'app/models/kirgudu_base/dynamic_pages/form_builder.rb', line 43
def properties(&block)
elements = ::KirguduBase::DynamicPages::FormPropertiesBlockBuilder.new(&block).to_elements
elements.each do |element|
self.builder_options[:properties] = {} unless self.builder_options[:properties]
self.builder_options[:properties][element.name] = element
end
end
|
#to_element ⇒ Object
64
65
66
67
68
69
|
# File 'app/models/kirgudu_base/dynamic_pages/form_builder.rb', line 64
def to_element
element = ::KirguduBase::DynamicPages::Form.new
self.build_element(element)
self.validate_generated_element(element)
element
end
|
#url(value) ⇒ Object
19
20
21
|
# File 'app/models/kirgudu_base/dynamic_pages/form_builder.rb', line 19
def url(value)
self.builder_options[:url] = value
end
|
#url_path(controller, action, params = {}) ⇒ Object
23
24
25
26
27
28
29
|
# File 'app/models/kirgudu_base/dynamic_pages/form_builder.rb', line 23
def url_path(controller, action, params = {})
self.builder_options[:url_path] = {
controller: controller,
action: action,
params: params
}
end
|