diff --git a/src/Form/Expression/ContextFormTrait.php b/src/Form/Expression/ContextFormTrait.php
index 65aeacc..fff5073 100644
--- a/src/Form/Expression/ContextFormTrait.php
+++ b/src/Form/Expression/ContextFormTrait.php
@@ -108,27 +108,30 @@ trait ContextFormTrait {
    */
   protected function getContextConfigFromFormValues(FormStateInterface $form_state, array $context_definitions) {
     $context_config = ContextConfig::create();
-    foreach ($form_state->getValue('context') as $context_name => $value) {
-      if ($form_state->get("context_$context_name") == 'selector') {
-        $context_config->map($context_name, $value['setting']);
-      }
-      else {
-        // Each line of the textarea is one value for multiple contexts.
-        if ($context_definitions[$context_name]->isMultiple()) {
-          $values = explode("\n", $value['setting']);
-          $context_config->setValue($context_name, $values);
+    if (!empty($form_state->getValue('context'))) {
+      foreach ($form_state->getValue('context') as $context_name => $value) {
+        if ($form_state->get("context_$context_name") == 'selector') {
+          $context_config->map($context_name, $value['setting']);
         }
         else {
-          $context_config->setValue($context_name, $value['setting']);
-        }
-        // For now, always add in the token context processor - if it's present.
-        // @todo: Improve this in https://www.drupal.org/node/2804035.
-        if ($this->getDataProcessorManager()->getDefinition('rules_tokens')) {
-          $context_config->process($context_name, 'rules_tokens');
+          // Each line of the textarea is one value for multiple contexts.
+          if ($context_definitions[$context_name]->isMultiple()) {
+            $values = explode("\n", $value['setting']);
+            $context_config->setValue($context_name, $values);
+          }
+          else {
+            $context_config->setValue($context_name, $value['setting']);
+          }
+          // For now, always add in the token context processor - if it's present.
+          // @todo: Improve this in https://www.drupal.org/node/2804035.
+          if ($this->getDataProcessorManager()->getDefinition('rules_tokens')) {
+            $context_config->process($context_name, 'rules_tokens');
+          }
         }
       }
     }
 
+
     return $context_config;
   }
 
