Custom module/theme callbacks errors

Created on 4 September 2023, 10 months ago

Problem/Motivation

After adding a custom after build callback on a widget/form alter ParagraphsAsymmetricWidget formElement method returns an error.

Steps to reproduce

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).

Proposed resolution

Add is_array check-up in the ParagraphAsymmetricWidget.

πŸ› Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine paulrad

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024