After adding a custom after build callback on a widget/form alter ParagraphsAsymmetricWidget formElement method returns an error.
Environment: D9, Inline Entity Form (complex widget is used).
1. Create an Entity Reference Revisions field with some paragraph reference.
2. Set "Inline entity form - Complex" widget for the field.
3. Enable asymmetric translation for the field.
4. In your custom module add "#after_build" callback within this module with hook_field_widget_single_element_WIDGET_TYPE_form_alter()
Example:
function my_custom_module_field_widget_single_element_inline_entity_form_complex_form_alter(array &$element, FormStateInterface $form_state, array $context): void {
$element['#after_build'][] = '_my_custom_module_new_after_build_callback';
}
5. Open node add form.
Output:
The website encountered an unexpected error. Please try again later.
TypeError: in_array(): Argument #2 ($haystack) must be of type array, string given in in_array() (line 33 of modules/contrib/paragraphs_asymmetric_translation_widgets/src/Plugin/Field/FieldWidget/ParagraphsAsymmetricWidget.php).
Add is_array
check-up in the ParagraphAsymmetricWidget.
Needs review
1.0
Code