- Issue created by @Grevil
- Merge request !13Issue #3521955: Error thrown, when paragraphs field allows all paragraph types → (Closed) created by Grevil
- 🇩🇪Germany Grevil
No i will take care this just add ?? []
Yes exactly, we are returning an empty array, so this code:
$options = $this->getFieldsParagraphs(); if (!empty($options)) { $elements['field_reference'] = [ '#type' => 'select', '#options' => $options, '#empty_option' => $this->t('- Select -'), '#title' => $this->t('Reference field'), '#description' => $this->t('Add button multi search on reference'), '#default_value' => $this->getSetting('field_reference'), '#states' => [ 'invisible' => [":input[name='fields[$field_name][settings_edit_form][settings][paste_clipboard]']" => ['checked' => FALSE]], ], ]; }
Won't ever get accessed, as $options is empty. Your adjustments are definitly incorrect and will lead to a new error:
Drupal\Core\Entity\EntityStorageException: Missing bundle for entity type paragraph in Drupal\Core\Entity\ContentEntityStorageBase->doCreate() (line 125 of core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php).
I just wanted to provide a quick fix for this issue. The implementation of "getFieldsParagraphs" generally feels a bit weird. We can not simply check the field definitions of the first target bundle in the "target_bundles" array, as they can differ from bundle to bundle.
- cda1672a committed on 2.x
Issue #3521955 by lazzyvn: Error thrown, when paragraphs field allows...
- cda1672a committed on 2.x
- 🇩🇪Germany Anybody Porta Westfalica
@lazzyvn wouldn't it be fair to credit @grevil and me?