]> _ Git - ccv-wordpress.git/commitdiff
Improvements to form handling - customised subject lines. WIP #3053 @0.75
authorStephen Cameron <stephen@cubedesigners.com>
Thu, 29 Oct 2020 09:29:00 +0000 (10:29 +0100)
committerStephen Cameron <stephen@cubedesigners.com>
Thu, 29 Oct 2020 09:29:00 +0000 (10:29 +0100)
wp-content/mu-plugins/cube/src/Forms/Base.php
wp-content/mu-plugins/cube/src/Forms/Consultation.php
wp-content/mu-plugins/cube/src/Forms/Contact.php
wp-content/mu-plugins/cube/src/Forms/Training.php

index 0bf5a882ae1f03e43be4e6ac98731b349169ac1b..8fa971089a2faec3200ee5f34bfb85d430059af9 100644 (file)
@@ -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;
index 7a16b3dcfcf2a2473ac12a47a075535ec1832faf..1ee457b5b0a32ed776879b6c8e40b7e4ba5a9c85 100644 (file)
@@ -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...
index 89c5212160bfda35a3d4396bc2cdb2c6bfc59cb6..2c13b9e16b8a2cbcc551fee67545ddbc866fba9f 100644 (file)
@@ -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);
+    }
 }
index ac7fa69c532ab88703b84e26f1b5678ce85d3d07..9756be1cd6ecdcfd9f84fff7b7faa1c228f4de5b 100644 (file)
@@ -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);
+    }
 }