localgovdrupal / localgov_microsites

A repository for the LocalGov Drupal Microsites project.
GNU General Public License v2.0
4 stars 2 forks source link

Contact forms for each microsite #235

Closed finnlewis closed 1 year ago

finnlewis commented 2 years ago

User story

As a microsite editor

I want to have a simple contact form for which I can configure the destination email

So that we can encourage visitors to get in touch with us.

Notes:

In the microsites working group meeting this was considered a must have feature. Notes are here: https://docs.google.com/document/d/1Y63d87PP6gc89m01NjJRUwsLzv5GWxRxDXgRG3-vbM4/edit#heading=h.lmjuqvwm89xn

The current understanding is that webform will not work with group module 1.x, as we can't easily assign config entities to a group. group 2.x / 3.x might allow us to pursue this path.

In the mean time it is worth exploring the Drupal core contact form module. Does it play nice?

stephen-cox commented 2 years ago

The core contact forms are also config entities so, like Webform, there's no easy way to make these into Group managed content.

If we're only going to have a few of these, we could look at giving Microsite Controllers the ability to create them and assign them to a site, but I can't see any easy way to allow site admins and editors to create them.

msayoung commented 2 years ago

Angie sent over these as examples, with the message:

Here are screenshots of to of two contact forms currently used. The fostering form was created by an external org and has basic branching.

Croydon Safeguarding Children Partnership.pdf Fostering Enquiry Contact Form1.pdf Fostering Enquiry Contact Form2.pdf Fostering Enquiry Contact Form3.pdf Fostering Enquiry Contact Form4.pdf Fostering Enquiry Contact Form5.pdf Fostering Enquiry Contact Form6.pdf

finnlewis commented 2 years ago

I think we need to create a solution for this.

@ekes and @stephen-cox were discussing embedding a webform in a node and passing config from the node fields to the embedded webform to override certain fields / config values.

Is this a goer?

finnlewis commented 2 years ago

@stephen-cox perhaps we discuss the feasibility of Group 3.x with @ekes first, at which point Drupal core contact forms should be easier.

If we're not going the Group 3.x route, we look at the "embedding a webform in a node and passing config" route.

If we are going the Group 3.x route... we might have more flexibility.

finnlewis commented 2 years ago

embedding a webform in a node and passing config from the node fields to the embedded webform to override certain fields / config values.

@ekes has done this in the past.

If we can get away with:

Then maybe this will be quick!

willguv commented 2 years ago

@finnlewis @ekes I think this a good workaround, thanks. We should mention this along with a move to group 3.x when available which will open up the possibility of integrating with Croydon's Webforms work

finnlewis commented 1 year ago

@ekes has made a start on this.

Scenario 1:

Scenario 2:

Scenario 1 does not rule out extending to scenario 2.

ekes commented 1 year ago

Super basic foundation for Scenario 1 https://github.com/localgovdrupal/group_webform I'm unsure if it should be a generic module, with a localgov_microsites_webform submodule tweaking it, or if we should just go in and customize for our specific use case in a module that declares the group relatioship type.

Presently the code is based on gnode, it's kinda the basic you need to make a relationship to entity type in a group. Everything ends up with the default group content urls and admin lists. So they probably want tweaking.

Permission options are too. Turning on and off individual webforms would then be a group_permissions task -- like turning off content types: events, news etc.

For mailing forms etc. it should be possible to use tokens. The site admin email for example is different per domain, so a token for that value would send it to the domains email address. Tokens can also be used to get values from where webforms are embedded, depending how this is done.

finnlewis commented 1 year ago

@finnlewis to test this!

finnlewis commented 1 year ago

My testing is looking promising, but I need to work out the list of tasks to make this operational.

Currently I have done the following:

  1. Cloned the https://github.com/localgovdrupal/group_webform module and enable it
  2. Enable the plugin at https://localgov-micro.lndo.site/admin/group/types/manage/microsite/content (Group webform (Contact)).
  3. Set permissions at https://localgov-micro.lndo.site/admin/group/types/manage/microsite/permissions set admin permissions to grant :

Entity: Add submission entities Entity: Delete any submission entities Entity: Delete own submission entities Entity: Edit any submission entities Entity: Edit own submission entities Entity: View any submission entities

  1. Find the url of the contact from from https://localgov-micro-1.lndo.site/group/1/content/create (listing all entities that we can creat)
  2. As anonymous, go to https://localgov-micro-1.lndo.site/group/1/content/create/group_webform%3Acontact
  3. See webform and make a submission
  4. As anonymous, go to https://localgov-micro-2.lndo.site/group/1/content/create/group_webform%3Acontact
  5. As admin 1 on site 1 visit https://localgov-micro-1.lndo.site/admin/structure/webform/manage/contact/submission/1 and see the sumbission
  6. As admin 2 on site 2 visit https://localgov-micro-2.lndo.site/admin/structure/webform/manage/contact/submission/1 and see access denied (so group permissions work!)
  7. As anon visit both of the above and see access denied.
finnlewis commented 1 year ago

Next up, need an itemised list of tasks to make this usable.

  1. Allow the webform to be embedded in a paragraph.
  2. Provide a way for the site admin to override the target email address for submissions to be sent to.
  3. Provide a listing of webform submissions on the microsite
msayoung commented 1 year ago

Notes

Image

Styling

Access.

2 microsites each with one webform each

/node/5 belongs to microsite 2 http://localgov-micro-1.lndo.site/node/5/webform/results/submissions - can access this page though there are no submissions

msayoung commented 1 year ago

we also need to enable the localgov_microsites_group_webform module in the profile

msayoung commented 1 year ago

and finally, do we want microsite controllers to be able to create webforms ? currently they can't

msayoung commented 1 year ago

I've added a couple of things here: https://github.com/localgovdrupal/localgov_microsites_group/pull/347 for your review @finnlewis

msayoung commented 1 year ago

Styling changes here: https://github.com/localgovdrupal/localgov_microsites_base/pull/180

finnlewis commented 1 year ago

We've merged this in now, good work all!