- Issue created by @sahaj
- 🇨🇦Canada joseph.olstad
@sahaj, thanks for reporting.
Which versions have you tried? What version did you upgrade from?
I'd like to narrow this down, please provide more information.
- Status changed to Postponed: needs info
over 1 year ago 3:17pm 12 June 2023 - 🇨🇦Canada joseph.olstad
I tested this and was able to add a new media image and did not see an error, maybe my steps were incorrect? on our setup the name field is mandatory. Maybe it has to be left empty and optional?
- Status changed to Closed: cannot reproduce
over 1 year ago 3:33pm 12 June 2023 - 🇨🇦Canada joseph.olstad
Unable to reproduce!
If you provide more information about this issue I will re-investigate.
Until then, cannot reproduce.
- Status changed to Active
about 1 year ago 6:10pm 12 October 2023 - 🇷🇺Russia k.prozorov
Hello.
I'm running into the same problem.
To reproduce the problem, you need to follow the steps:
- install pure drupal 9.5.11 (drupal/recommended-project)
- install and enable the entity_translation_unified_form module (version 2.0.0)
- add two additional languages (/admin/config/regional/language), so that there would be 3 languages
- set up translation for the type of material, for example, for articles (/admin/config/regional/content-language) as in the screenshot
- try to upload a pictureIn this case, there is an error in the console and in watchdog:
Error: Call to a member function getName() on null in Drupal\content_translation\ContentTranslationHandler->entityFormAlter() (line 353 of /app/web/core/modules/content_translation/src/ContentTranslationHandler.php) #0 /app/web/core/modules/node/src/NodeTranslationHandler.php(18): Drupal\content_translation\ContentTranslationHandler->entityFormAlter(Array, Object(Drupal\Core\Form\FormState), Object(Drupal\node\Entity\Node)) #1 /app/web/core/modules/content_translation/content_translation.module(399): Drupal\node\NodeTranslationHandler->entityFormAlter(Array, Object(Drupal\Core\Form\FormState), Object(Drupal\node\Entity\Node)) #2 /app/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(562): content_translation_form_alter(Array, Object(Drupal\Core\Form\FormState), 'node_article_fo...') #3 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(840): Drupal\Core\Extension\ModuleHandler->alter('form', Array, Object(Drupal\Core\Form\FormState), 'node_article_fo...') #4 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(434): Drupal\Core\Form\FormBuilder->prepareForm('node_article_fo...', Array, Object(Drupal\Core\Form\FormState)) #5 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(633): Drupal\Core\Form\FormBuilder->rebuildForm('node_article_fo...', Object(Drupal\Core\Form\FormState), Array) #6 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(325): Drupal\Core\Form\FormBuilder->processForm('node_article_fo...', Array, Object(Drupal\Core\Form\FormState)) #7 /app/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\node\NodeForm), Object(Drupal\Core\Form\FormState)) #8 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch)) #9 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) #10 /app/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #11 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #12 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) #13 /app/vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #14 /app/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #15 /app/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #16 /app/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #17 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #18 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #19 /app/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #20 /app/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #21 /app/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #22 /app/web/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #23 /app/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #24 {main}
I found a temporary solution that helped, in the file core/modules/content_translation/src/ContentTranslationHandler.php commented out the code (which adds a language switch field):
if ($has_translations && $new_translation) { $source_langcode = $metadata->getSource(); $form['source_langcode'] = [ '#type' => 'details', '#title' => t('Source language: @language', ['@language' => $languages[$source_langcode]->getName()]), '#tree' => TRUE, '#weight' => -100, '#multilingual' => TRUE, 'source' => [ '#title' => t('Select source language'), '#title_display' => 'invisible', '#type' => 'select', '#default_value' => $source_langcode, '#options' => [], ], 'submit' => [ '#type' => 'submit', '#value' => t('Change'), '#submit' => [[$this, 'entityFormSourceChange']], ], ]; foreach ($this->languageManager->getLanguages() as $language) { if (isset($translations[$language->getId()])) { $form['source_langcode']['source']['#options'][$language->getId()] = $language->getName(); } } }
In my case, the problem was solved, since I don't need a language switch, because the default language is set in the settings (/admin/config/regional/content-language), and I see all the translated fields at once, but this is not a good solution.
- 🇨🇦Canada joseph.olstad
Hi k.prozorov,
Yes this can get a bit confusing and can depend on what language your team members usually use, your approach is one option.In my clients setups I'll usually not allow changing the language value, it will be the current interface language, this is an option.
Alternatively you can set it to the site language default.when editing content that has a source language other than the current language , only the translateable values will be editable.
to edit the non translateable values you'd have to switch to the source language.