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, ResponseFieldParagraph, ResponseFieldPrice, ResponseFieldRadio, ResponseFieldSectionBreak, 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
|
#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
78
79
|
# File 'app/models/formbuilder/response_field.rb', line 78
def audit_response(value, all_responses)
end
|
#has_length_validations? ⇒ Boolean
49
50
51
|
# File 'app/models/formbuilder/response_field.rb', line 49
def has_length_validations?
length_validations(false).any?
end
|
#length_validations(include_units = true) ⇒ Object
38
39
40
41
42
43
44
45
46
47
|
# File 'app/models/formbuilder/response_field.rb', line 38
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
53
54
55
56
57
58
59
60
|
# File 'app/models/formbuilder/response_field.rb', line 53
def min_max_validations
return_hash = {
min: field_options[:min],
max: field_options[:max]
}
return_hash.select { |k, v| v.present? }
end
|
#render_entry(value, opts = {}) ⇒ Object
74
75
76
|
# File 'app/models/formbuilder/response_field.rb', line 74
def render_entry(value, opts = {})
value
end
|
#render_entry_for_table(value, opts = {}) ⇒ Object
62
63
64
65
66
67
68
|
# File 'app/models/formbuilder/response_field.rb', line 62
def render_entry_for_table(value, opts = {})
"""
<td data-column-id='#{self.id}'>
#{render_entry(value, opts)}
</td>
"""
end
|
70
71
72
|
# File 'app/models/formbuilder/response_field.rb', line 70
def render_input(value, opts = {})
raise 'Not implemented'
end
|
#validate_response(value) ⇒ Object
81
82
|
# File 'app/models/formbuilder/response_field.rb', line 81
def validate_response(value)
end
|