Class: Formbuilder::ResponseFieldEmail
- Inherits:
-
ResponseField
- Object
- ActiveRecord::Base
- ResponseField
- Formbuilder::ResponseFieldEmail
- Includes:
- ActionView::Helpers::TagHelper
- Defined in:
- app/models/formbuilder/response_field_email.rb
Constant Summary
Constants inherited from ResponseField
Formbuilder::ResponseField::ALLOWED_PARAMS
Instance Attribute Summary
Attributes inherited from ResponseField
#cid, #field_type, #input_field, #options_field, #serialized, #sort_as_numeric
Instance Method Summary collapse
- #render_entry(value, opts = {}) ⇒ Object
- #render_input(value, opts = {}) ⇒ Object
- #validate_response(value) ⇒ Object
Methods inherited from ResponseField
#audit_response, #has_length_validations?, #length_validations, #min_max_validations, #render_entry_for_table
Instance Method Details
#render_entry(value, opts = {}) ⇒ Object
15 16 17 |
# File 'app/models/formbuilder/response_field_email.rb', line 15 def render_entry(value, opts = {}) "<a href='mailto:#{value}'>#{value}</a>" end |
#render_input(value, opts = {}) ⇒ Object
10 11 12 13 |
# File 'app/models/formbuilder/response_field_email.rb', line 10 def render_input(value, opts = {}) tag(:input, type: 'text', name: "response_fields[#{self.id}]", class: "rf-size-#{self[:field_options]['size']}", data: self.length_validations, value: value) end |
#validate_response(value) ⇒ Object
19 20 21 22 23 |
# File 'app/models/formbuilder/response_field_email.rb', line 19 def validate_response(value) unless value =~ /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i "isn't a valid email address." end end |