diff --git a/modules/civiremote_entity/src/Form/Control/FileArrayFactory.php b/modules/civiremote_entity/src/Form/Control/FileArrayFactory.php index 224c33d..ec853a1 100644 --- a/modules/civiremote_entity/src/Form/Control/FileArrayFactory.php +++ b/modules/civiremote_entity/src/Form/Control/FileArrayFactory.php @@ -61,26 +61,30 @@ public function createFormArray( ] + BasicFormPropertiesFactory::createFieldProperties($definition, $formState), ]; - if (($form['file']['#default_value'] ?? NULL) instanceof \stdClass - && is_string($form['file']['#default_value']->url ?? NULL) - && is_string($form['file']['#default_value']->filename ?? NULL) - ) { - $url = $form['file']['#default_value']->url; - $filename = $form['file']['#default_value']->filename; - - $form['file']['#required'] = FALSE; - - $form['link'] = [ - '#type' => 'link', - '#title' => $filename, - '#url' => $this->civiCRMUrlManager->addRemoteUrl($url, $filename), - '#attributes' => ['target' => '_blank'], - '#prefix' => '
', - '#suffix' => '
', - ]; - - if (isset($form['file']['#states'])) { - $form['link']['#states'] = $form['file']['#states']; + if (isset($form['file']['#default_value'])) { + // If the default value was fetched from the temporary values, it should + // be an array. If it was fetched from the field definition, it should be + // an \stdClass. + /** @phpstan-var \stdClass|array', + '#suffix' => '
', + ]; + + if (isset($form['file']['#states'])) { + $form['link']['#states'] = $form['file']['#states']; + } } }