Class: Plugins::CamaContactForm::FrontController
- Inherits:
-
CamaleonCms::Apps::PluginsFrontController
- Object
- CamaleonCms::Apps::PluginsFrontController
- Plugins::CamaContactForm::FrontController
- Includes:
- ContactFormControllerConcern, MainHelper
- Defined in:
- app/controllers/plugins/cama_contact_form/front_controller.rb
Instance Method Summary collapse
-
#save_form ⇒ Object
here add your custom functions.
Instance Method Details
#save_form ⇒ Object
here add your custom functions
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/plugins/cama_contact_form/front_controller.rb', line 6 def save_form flash[:contact_form] = {} @form = current_site.contact_forms.find_by_id(params[:id]) fields = params[:fields] errors = [] success = [] args = {form: @form, values: fields, flag: true}; hooks_run("contact_form_before_submit", args) if args[:flag] perform_save_form(@form, fields, success, errors) if success.present? flash[:contact_form][:notice] = success.join('<br>') else flash[:contact_form][:error] = errors.join('<br>') flash[:values] = fields.delete_if{|k, v| v.class.name == 'ActionDispatch::Http::UploadedFile' } end end if Rails::VERSION::MAJOR >= 5 params[:format] == 'json' ? render(json: flash.discard(:contact_form).to_hash) : (redirect_back fallback_location: cama_root_path) else params[:format] == 'json' ? render(json: flash.discard(:contact_form).to_hash) : (redirect_to :back) end end |