Class: Plugins::CamaContactForm::CamaContactForm
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Plugins::CamaContactForm::CamaContactForm
- Includes:
- MainHelper
- Defined in:
- app/models/plugins/cama_contact_form/cama_contact_form.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#fields ⇒ Object
["label":"Untitled","field_type":"text","required":true,"field_options":{"size":"large","field_class":"Default","cid":"c2"},"label":"Untitled","field_type":"paragraph","required":true,"field_options":{"size":"large","field_class":"Default","cid":"c6"},"label":"Untitled","field_type":"captcha","required":true,"field_options":{"field_class":"Default","cid":"c10"},"label":"Untitled","field_type":"checkboxes","required":true,"field_options":{"options":[{"label":"Default","checked":false,"label":"Default","checked":false],"field_class":"Default","description":"description\n"},"cid":"c12"}].
- #form_button_settings ⇒ Object
-
#mail_settings ⇒ Object
The three settings containers, always readable.
- #message_settings ⇒ Object
-
#recaptcha_enabled? ⇒ Boolean
verify if recaptcha was enabled for this form this method can be overwritten if recaptcha was already defined on initializers to return true as default.
-
#set_captcha_settings! ⇒ Object
define recaptcha settings.
- #the_message(key, default) ⇒ Object
- #the_settings ⇒ Object
Class Method Details
.field_template ⇒ Object
48 49 50 |
# File 'app/models/plugins/cama_contact_form/cama_contact_form.rb', line 48 def self.field_template "<div class='form-group'>\n\t <label>[label ci]</label>\n\t<p>[descr ci]</p>\n\t<div>[ci]</div> \n</div>" end |
Instance Method Details
#fields ⇒ Object
["label":"Untitled","field_type":"text","required":true,"field_options":{"size":"large","field_class":"Default","cid":"c2"},"label":"Untitled","field_type":"paragraph","required":true,"field_options":{"size":"large","field_class":"Default","cid":"c6"},"label":"Untitled","field_type":"captcha","required":true,"field_options":{"field_class":"Default","cid":"c10"},"label":"Untitled","field_type":"checkboxes","required":true,"field_options":{"options":[{"label":"Default","checked":false,"label":"Default","checked":false],"field_class":"Default","description":"description\n"},"cid":"c12"}]
18 19 20 21 |
# File 'app/models/plugins/cama_contact_form/cama_contact_form.rb', line 18 def fields @_the_fields ||= JSON.parse(self.value || '{"fields": []}').with_indifferent_access Array(@_the_fields[:fields]) end |
#form_button_settings ⇒ Object
35 36 37 |
# File 'app/models/plugins/cama_contact_form/cama_contact_form.rb', line 35 def settings_hash(:railscf_form_button) end |
#mail_settings ⇒ Object
The three settings containers, always readable. A form that has never been saved carries
settings of {}, and a partial update can leave any of them unset -- so every caller in the
admin views guards its read with rescue '', while the ones that do not (the public shortcode,
the mailer) raised NoMethodError on every request until someone edited the database by hand.
31 32 33 |
# File 'app/models/plugins/cama_contact_form/cama_contact_form.rb', line 31 def mail_settings settings_hash(:railscf_mail) end |
#message_settings ⇒ Object
39 40 41 |
# File 'app/models/plugins/cama_contact_form/cama_contact_form.rb', line 39 def settings_hash(:railscf_message) end |
#recaptcha_enabled? ⇒ Boolean
verify if recaptcha was enabled for this form this method can be overwritten if recaptcha was already defined on initializers to return true as default
64 65 66 |
# File 'app/models/plugins/cama_contact_form/cama_contact_form.rb', line 64 def recaptcha_enabled? the_settings[:recaptcha_site_key].present? end |
#set_captcha_settings! ⇒ Object
define recaptcha settings
53 54 55 56 57 58 59 60 |
# File 'app/models/plugins/cama_contact_form/cama_contact_form.rb', line 53 def set_captcha_settings! if recaptcha_enabled? Recaptcha.configure do |config| config.site_key = the_settings[:recaptcha_site_key] config.secret_key = the_settings[:recaptcha_secret_key] end end end |
#the_message(key, default) ⇒ Object
43 44 45 46 |
# File 'app/models/plugins/cama_contact_form/cama_contact_form.rb', line 43 def (key, default) r = [key].to_s.translate r.present? ? r : default end |
#the_settings ⇒ Object
23 24 25 |
# File 'app/models/plugins/cama_contact_form/cama_contact_form.rb', line 23 def the_settings @_the_settings ||= JSON.parse(self.settings || '{}').with_indifferent_access end |