Class: Formbuilder::ResponseField
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Formbuilder::ResponseField
show all
- Defined in:
- app/models/formbuilder/response_field.rb
Direct Known Subclasses
ResponseFieldAddress, ResponseFieldCheckboxes, ResponseFieldDate, ResponseFieldDropdown, ResponseFieldEmail, ResponseFieldFile, ResponseFieldNumber, ResponseFieldPageBreak, ResponseFieldParagraph, ResponseFieldPrice, ResponseFieldRadio, ResponseFieldSectionBreak, ResponseFieldTable, ResponseFieldText, ResponseFieldTime, ResponseFieldWebsite
Constant Summary
collapse
- ALLOWED_PARAMS =
[:key, :blind, :label, :field_options, :required, :admin_only]
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#cid ⇒ Object
For backbone saving compatibility
7
8
9
|
# File 'app/models/formbuilder/response_field.rb', line 7
def cid
@cid
end
|
#field_type ⇒ Object
Underscored name of this field
23
24
25
|
# File 'app/models/formbuilder/response_field.rb', line 23
def field_type
@field_type
end
|
Does this field take an input? (An example of a non-input field is a section break.)
11
12
13
|
# File 'app/models/formbuilder/response_field.rb', line 11
def input_field
@input_field
end
|
#options_field ⇒ Object
Does this field have a preset list of options?
14
15
16
|
# File 'app/models/formbuilder/response_field.rb', line 14
def options_field
@options_field
end
|
#search_type ⇒ Object
Search type for this field
26
27
28
|
# File 'app/models/formbuilder/response_field.rb', line 26
def search_type
@search_type
end
|
#serialized ⇒ Object
Do we need to serialize the response for this field?
17
18
19
|
# File 'app/models/formbuilder/response_field.rb', line 17
def serialized
@serialized
end
|
#sort_as_numeric ⇒ Object
Should we sort this field’s responses as numeric values?
20
21
22
|
# File 'app/models/formbuilder/response_field.rb', line 20
def sort_as_numeric
@sort_as_numeric
end
|
Instance Method Details
#audit_response(value, all_responses) ⇒ Object
77
|
# File 'app/models/formbuilder/response_field.rb', line 77
def audit_response(value, all_responses); end
|
#before_response_destroyed(entry) ⇒ Object
83
|
# File 'app/models/formbuilder/response_field.rb', line 83
def before_response_destroyed(entry); end
|
#has_length_validations? ⇒ Boolean
52
53
54
|
# File 'app/models/formbuilder/response_field.rb', line 52
def has_length_validations?
length_validations(false).any?
end
|
#length_validations(include_units = true) ⇒ Object
41
42
43
44
45
46
47
48
49
50
|
# File 'app/models/formbuilder/response_field.rb', line 41
def length_validations(include_units = true)
return_hash = {
minlength: field_options[:minlength],
maxlength: field_options[:maxlength]
}
return_hash[:min_max_length_units] = field_options[:min_max_length_units] if include_units
return_hash.select { |k, v| v.present? }
end
|
#min_max_validations ⇒ Object
56
57
58
59
60
61
62
63
|
# File 'app/models/formbuilder/response_field.rb', line 56
def min_max_validations
return_hash = {
min: field_options[:min],
max: field_options[:max]
}
return_hash.select { |k, v| v.present? }
end
|
#normalize_response(value, all_responses) ⇒ Object
79
|
# File 'app/models/formbuilder/response_field.rb', line 79
def normalize_response(value, all_responses); end
|
#options_array ⇒ Object
89
90
91
|
# File 'app/models/formbuilder/response_field.rb', line 89
def options_array
Array(self.field_options['options']).map { |o| o['label'] }
end
|
#render_entry(value, opts = {}) ⇒ Object
69
70
71
|
# File 'app/models/formbuilder/response_field.rb', line 69
def render_entry(value, opts = {})
value
end
|
#render_entry_text(value, opts = {}) ⇒ Object
73
74
75
|
# File 'app/models/formbuilder/response_field.rb', line 73
def render_entry_text(value, opts = {})
render_entry(value, opts)
end
|
65
66
67
|
# File 'app/models/formbuilder/response_field.rb', line 65
def render_input(value, opts = {})
raise 'Not implemented'
end
|
#sortable_value(value) ⇒ Object
93
94
95
|
# File 'app/models/formbuilder/response_field.rb', line 93
def sortable_value(value)
value[0..10] end
|
85
86
87
|
# File 'app/models/formbuilder/response_field.rb', line 85
def transform_raw_value(raw_value, entry, opts = {})
raw_value
end
|
#validate_response(value) ⇒ Object
81
|
# File 'app/models/formbuilder/response_field.rb', line 81
def validate_response(value); end
|