I’ve added some paragraph in my content type. In a paragraph, I’ve added another paragraph with some data, including a media inside another content type
When I’m trying to add a media, I have this in my console :
DrupalCoreRenderElement::children() must be of the type array, null
given modules/contrib/entity_browser/entity_browser.module
Caused by the foreach
part. First, I simply tried to add a condition around the foreach to see if ton only.
foreach (Element::children($form['actions']) != null
After, I had an error on the getEntity() on null
. What can I do has a patch to fix it without breaking the entity_browser ? Knowing that entity_browser works fine when I edit the media
function entity_browser_form_alter(&$form, FormStateInterface &$form_state) {
$entity_browser_dialog_edit = Drupal::service('request_stack')->getCurrentRequest()->get('_route');
if ($entity_browser_dialog_edit == 'entity_browser.edit_form') {
// Let's allow the save button only.
foreach (Element::children($form['actions']) as $key) {
$form['actions'][$key]['#access'] = $key == 'submit';
}
// Use Ajax.
$form['actions']['submit']['#ajax'] = [
'url' => Url::fromRoute('entity_browser.edit_form', ['entity_type' => $form_state->getFormObject()->getEntity()->getEntityTypeId(), 'entity' => $form_state->getFormObject()->getEntity()->id()]),
'options' => [
'query' => [
'details_id' => Drupal::request()->query->get('details_id'),
],
],
'disable-refocus' => TRUE,
];
}
}
This is basicaly my structure :
| - Page
| ---- Paragraph
| - Slider
| - Slide
| - Content type
| - Media
| - Slide
| - Content type
| - Media