- π·π΄Romania reszli TΓ’rgu MureΘ
we ran into this issue as well, with a list<string> on a user profile form
and we found the following workaround:$language_manager = \Drupal::languageManager(); $current_language = $language_manager->getConfigOverrideLanguage(); $language_manager->setConfigOverrideLanguage($current_language); $field_storage = \Drupal::entityTypeManager() ->getStorage('field_storage_config') ->loadUnchanged('user.[FIELD_NAME]''); $allowed_values = $field_storage->getSetting('allowed_values'); // Do your things here. // ... i.e. overriding the widget options in the user form $form['[FIELD_NAME]'']['widget']['#options'] = $allowed_values; // Revert to the original language. <== not needed in our case // $language_manager->setConfigOverrideLanguage($current_language);
or this is how it would look like in case of a node field:
$language_manager = \Drupal::languageManager(); $current_language = $language_manager->getConfigOverrideLanguage(); // Load translated allowed values for the field by overriding config // language temporary. $language_manager->setConfigOverrideLanguage($node->language()); $field_storage = \Drupal::entityTypeManager() ->getStorage('field_storage_config') ->loadUnchanged('node.[FIELD_NAME]'); $allowed_values = $field_storage->getSetting('allowed_values'); // Do your things here. ... // Revert to the original language. $language_manager->setConfigOverrideLanguage($current_language);