From 996bdd711c2cd07404c2d15b77b115d11dd1e1ed Mon Sep 17 00:00:00 2001
From: Liam Morland <lkmorlan@uwaterloo.ca>
Date: Mon, 20 Feb 2023 19:59:49 +0000
Subject: [PATCH] Issue #3063023: Mark required backend settings #required

---
 src/Form/FillPdfSettingsForm.php | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/Form/FillPdfSettingsForm.php b/src/Form/FillPdfSettingsForm.php
index 8dcf656..c8aa581 100644
--- a/src/Form/FillPdfSettingsForm.php
+++ b/src/Form/FillPdfSettingsForm.php
@@ -246,12 +246,22 @@ class FillPdfSettingsForm extends ConfigFormBase {
       '#title' => $this->t('Server endpoint'),
       '#default_value' => $config->get('remote_endpoint'),
       '#description' => $this->t('The endpoint for the FillPDF Service instance. Do not include the protocol, as this is determined by the <em>Use HTTPS?</em> setting below.'),
+      '#states' => [
+        'required' => [
+          ':input[name="backend"]' => ['value' => 'fillpdf_service'],
+        ],
+      ],
     ];
     $form['fillpdf_service']['fillpdf_service_api_key'] = [
       '#type' => 'textfield',
       '#title' => $this->t('API Key'),
       '#default_value' => $config->get('fillpdf_service_api_key'),
       '#description' => $this->t('You need to get an API key from your service.'),
+      '#states' => [
+        'required' => [
+          ':input[name="backend"]' => ['value' => 'fillpdf_service'],
+        ],
+      ],
     ];
     $form['fillpdf_service']['remote_protocol'] = [
       '#type' => 'radios',
@@ -281,6 +291,11 @@ class FillPdfSettingsForm extends ConfigFormBase {
       '#default_value' => $config->get('local_service_endpoint'),
       '#description' => $this->t("Enter the network address of your FillPDF LocalServer installation. If you are running the Docker container on port 8085 locally, then the address is <em>http://127.0.0.1:8085</em>."),
       '#group' => 'local_server',
+      '#states' => [
+        'required' => [
+          ':input[name="backend"]' => ['value' => 'local_server'],
+        ],
+      ],
     ];
 
     $form['pdftk'] = [
-- 
GitLab