From 7b6489a252bb1388310768f86decd8b8a5a6aab9 Mon Sep 17 00:00:00 2001 From: Summer Cook Date: Thu, 24 Aug 2023 15:44:16 -0300 Subject: [PATCH] Fix broken contact form and negative captcha compared to the hyrax contact form, some seemingly crucial methods were missing that was causing the form to display an error page. This should also fix the negative captcha issue Related - https://github.com/scientist-softserv/atla-hyku/issues/19 --- app/controllers/hyrax/contact_form_controller.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/controllers/hyrax/contact_form_controller.rb b/app/controllers/hyrax/contact_form_controller.rb index 4a1c1c7d..5cb7fb89 100644 --- a/app/controllers/hyrax/contact_form_controller.rb +++ b/app/controllers/hyrax/contact_form_controller.rb @@ -14,6 +14,7 @@ class ContactFormController < ApplicationController include Blacklight::SearchHelper include Blacklight::AccessControls::Catalog layout 'homepage' + before_action :build_contact_form # OVERRIDE: Adding inject theme views method for theming around_action :inject_theme_views before_action :setup_negative_captcha, only: %i[new create] @@ -44,7 +45,7 @@ def new # OVERRIDE: Hyrax 3.4.0 add @featured_collection_list @featured_collection_list = FeaturedCollectionList.new @announcement_text = ContentBlock.for(:announcement) - end + end def create # not spam, form is valid, and captcha is valid @@ -78,6 +79,15 @@ def after_deliver; end private + def build_contact_form + @contact_form = model_class.new(contact_form_params) + end + + def contact_form_params + return {} unless params.key?(:contact_form) + params.require(:contact_form).permit(:contact_method, :category, :name, :email, :subject, :message) + end + # OVERRIDE: return collections for theming def collections(rows: 6) builder = Hyrax::CollectionSearchBuilder.new(self)