diff --git a/core/lib/Drupal/Core/Form/SubformState.php b/core/lib/Drupal/Core/Form/SubformState.php
index 50f3911..40bcce3 100644
--- a/core/lib/Drupal/Core/Form/SubformState.php
+++ b/core/lib/Drupal/Core/Form/SubformState.php
@@ -73,6 +73,12 @@ public static function createForSubform(array &$subform, array &$parent_form, Fo
   protected function getParents($property) {
     foreach ([$this->subform, $this->parentForm] as $form) {
       if (!isset($form[$property]) || !is_array($form[$property])) {
+        // If the form is not processing input, #parents may not be present.
+        // Return an empty array instead of throwing an exception.
+        if (!$this->isProcessingInput()) {
+          return [];
+        }
+
         throw new \RuntimeException(sprintf('The subform and parent form must contain the %s property, which must be an array. Try calling this method from a #process callback instead.', $property));
       }
     }
