From c6995902e40f309ea982e1cb256ab3151c7efe0d Mon Sep 17 00:00:00 2001 From: Stephen Cameron Date: Thu, 29 Oct 2020 10:29:00 +0100 Subject: [PATCH] Improvements to form handling - customised subject lines. WIP #3053 @0.75 --- wp-content/mu-plugins/cube/src/Forms/Base.php | 10 ++++++++++ wp-content/mu-plugins/cube/src/Forms/Consultation.php | 5 ++++- wp-content/mu-plugins/cube/src/Forms/Contact.php | 7 ++++++- wp-content/mu-plugins/cube/src/Forms/Training.php | 7 ++++++- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/wp-content/mu-plugins/cube/src/Forms/Base.php b/wp-content/mu-plugins/cube/src/Forms/Base.php index 0bf5a88..8fa9710 100644 --- a/wp-content/mu-plugins/cube/src/Forms/Base.php +++ b/wp-content/mu-plugins/cube/src/Forms/Base.php @@ -296,6 +296,16 @@ class Base return $this->destination; } + public function set_form_title($title = '', $append = false) { + if (!empty($title)) { + if ($append) { + $this->form_title .= $title; + } else { + $this->form_title = $title; + } + } + } + public function set_destination($address = '') { if (!empty($address)) { $this->destination = $address; diff --git a/wp-content/mu-plugins/cube/src/Forms/Consultation.php b/wp-content/mu-plugins/cube/src/Forms/Consultation.php index 7a16b3d..1ee457b 100644 --- a/wp-content/mu-plugins/cube/src/Forms/Consultation.php +++ b/wp-content/mu-plugins/cube/src/Forms/Consultation.php @@ -17,7 +17,7 @@ use function Roots\asset; class Consultation extends Base { public function __construct() { - $this->form_title = __('Formulaire de consultation', 'ccv'); + $this->set_form_title(__('Formulaire de consultation', 'ccv')); } public function register_scripts() { @@ -123,6 +123,9 @@ class Consultation extends Base public function pre_process() { + // Include patient name in subject line + $this->set_form_title(' - '. strtoupper($this->get_data('last-name')) .', '. $this->get_data('first-name') , true); + // Due to the complexity of the "Imagery" section of the form, there's no validation on these fields // so it's possible to submit the form without ever selecting an imagery-type. In this case, we update // the field value so it is clear to CCV that the client never filled out this section... diff --git a/wp-content/mu-plugins/cube/src/Forms/Contact.php b/wp-content/mu-plugins/cube/src/Forms/Contact.php index 89c5212..2c13b9e 100644 --- a/wp-content/mu-plugins/cube/src/Forms/Contact.php +++ b/wp-content/mu-plugins/cube/src/Forms/Contact.php @@ -7,7 +7,7 @@ use Cube\Forms\Builder\Fields\Text; class Contact extends Base { public function __construct() { - $this->form_title = __('Formulaire de contact', 'ccv'); + $this->set_form_title(__('Formulaire de contact', 'ccv')); } function register_fields() { @@ -19,4 +19,9 @@ class Contact extends Base ]); } + + public function pre_process() { + // Include patient name in subject line + $this->set_form_title(' - '. strtoupper($this->get_data('last-name')) .', '. $this->get_data('first-name') , true); + } } diff --git a/wp-content/mu-plugins/cube/src/Forms/Training.php b/wp-content/mu-plugins/cube/src/Forms/Training.php index ac7fa69..9756be1 100644 --- a/wp-content/mu-plugins/cube/src/Forms/Training.php +++ b/wp-content/mu-plugins/cube/src/Forms/Training.php @@ -11,7 +11,7 @@ use Cube\Forms\Builder\Fields\Text; class Training extends Base { public function __construct() { - $this->form_title = __('Demande de formation', 'ccv'); + $this->set_form_title(__('Demande de formation', 'ccv')); } function register_fields() { @@ -65,4 +65,9 @@ class Training extends Base ]); } + + public function pre_process() { + // Include patient name in subject line + $this->set_form_title(' - '. strtoupper($this->get_data('last-name')) .', '. $this->get_data('first-name') , true); + } } -- 2.39.5