diff --git a/src/Form/FillPdfSettingsForm.php b/src/Form/FillPdfSettingsForm.php
index 8dcf656d0589dc72fc2d994fddea489502b91791..c8aa581364f4b7c2c98f57dae635d7000d668068 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'] = [