- 🇧🇷Brazil renatog Campinas
+++ b/better_formats.module @@ -10,6 +10,25 @@ use Drupal\Core\Form\FormStateInterface; +function better_formats_field_widget_form_alter(&$element, FormStateInterface $form_state, $context) { + $field_definition = $context['items']->getFieldDefinition(); + if (better_formats_is_text_format($field_definition->getType())) { + // Since $form object cannot be trusted to retrieve $entity and $field_name + // in better_formats_filter_process_format when using embed entities + // (with paragraphs, or inline_entity_form), let's handle it in field_widget_alter, + // where we can work with $context. + $element['#entity'] = $context['items']->getEntity(); + $element['#field_name'] = $context['items']->getName(); + } +}
I'd say that we can improve this logic with early return
- 🇧🇷Brazil renatog Campinas
The patch needs to be updated as well because it was implementing a hook_field_widget_form_alter but currently already have this hook at 8.x-1.x https://git.drupalcode.org/project/better_formats/-/blob/8.x-1.x/better_...