diff --git a/src/Form/LibraryForm.php b/src/Form/LibraryForm.php index 5322faf..82f185a 100644 --- a/src/Form/LibraryForm.php +++ b/src/Form/LibraryForm.php @@ -210,6 +210,15 @@ public function form(FormBuilderInterface $builder, array $options) : void FormData::persistTemporaryTranslation($address->getTranslations(), $langcode); } } else { + // Rarely an existing library without an address is found. If + // this is the case then the default language code needs to be + // set from the library otherwise the address insertion will fail. + $address = $data->getAddress(); + + if($address && !$address->getDefaultLangcode()) { + $address->setDefaultLangcode($data->getDefaultLangcode()); + } + $mail_address = $data->getMailAddress(); if($mail_address && !$mail_address->getDefaultLangcode()) {