- Issue created by @monymirza
- Status changed to Needs review
4 months ago 10:26am 29 August 2024
When media_library element is added inside webform_multiple, it throughs error.
Warning: Array to string conversion in /var/www/web/modules/contrib/media_library_form_element/src/Plugin/WebformElement/MediaLibrary.php on line 112
Creates a custom @WebformElement extends WebformElementBase
under public function form
, add
$form['images'] = [
'#type' => 'fieldset',
'#title' => $this->t('Image options'),
];
$form['images']['media'] = [
'#type' => 'webform_multiple',
'#element' => [
'image_label' => [
'#type' => 'textfield',
'#title' => $this->t('Label'),
],
'media_list' => [
'#type' => 'media_library',
'#allowed_bundles' => ['image'],
'#title' => $this->t('Image'),
'#cardinality' => 1,
],
],
'#add_more_button_label' => $this->t('Add more'),
'#add_more_input' => FALSE,
];
Replace line with
$element['#default_value'] = $element['#default_value']['media_library_selection'] ?? implode(',', $element['#default_value']);
Needs review
2.0
Code