- ๐ท๐ด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);
- ๐ซ๐ฎFinland sokru
@reszli thanks for the workaround, I tried to revert #2826021: FieldItemList::equals is sufficient from the storage perspective but not for code checking for changes โ but didn't have an effect.
Updated the IS that the case is also present with "List (text)" field type.