Skip to content

Commit

Permalink
Merge pull request #149 from scientist-softserv/contact-form-woes
Browse files Browse the repository at this point in the history
Fix broken contact form and negative captcha
  • Loading branch information
labradford authored Aug 24, 2023
2 parents 8cbd72c + 7b6489a commit 0a73e6c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/controllers/hyrax/contact_form_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 0a73e6c

Please sign in to comment.