Class: Plugins::CamaContactForm::CamaContactForm

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
MainHelper
Defined in:
app/models/plugins/cama_contact_form/cama_contact_form.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.field_templateObject



32
33
34
# File 'app/models/plugins/cama_contact_form/cama_contact_form.rb', line 32

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

#fieldsObject

“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”},href="{"label":"Default","checked":false,"label":"Default","checked":false">options”:,“field_class”:“Default”,“description”:“descriptionn”},“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
  @_the_fields[:fields]
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

Returns:

  • (Boolean)


48
49
50
# File 'app/models/plugins/cama_contact_form/cama_contact_form.rb', line 48

def recaptcha_enabled?
  the_settings[:recaptcha_site_key].present?
end

#set_captcha_settings!Object

define recaptcha settings



37
38
39
40
41
42
43
44
# File 'app/models/plugins/cama_contact_form/cama_contact_form.rb', line 37

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



27
28
29
30
# File 'app/models/plugins/cama_contact_form/cama_contact_form.rb', line 27

def the_message(key, default)
  r = self.the_settings[:railscf_message][key].to_s.translate
  r.present? ? r : default
end

#the_settingsObject



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