When creating a custom form and attaching a wysywyg like:
'#type' => 'text_format',
'#format' => 'panopoly_wysiwyg_text',
You get the errors below:
Warning: preg_match_all() expects parameter 2 to be string, array given in _media_generate_tagMap() (line 240 of /var/www/aaaa/www/profiles/panopoly/modules/contrib/media/includes/media.filter.inc).
Warning: Invalid argument supplied for foreach() in _media_generate_tagMap() (line 241 of /var/www/aaaa/www/profiles/panopoly/modules/contrib/media/includes/media.filter.inc).
Warning: htmlspecialchars() expects parameter 1 to be string, array given in check_plain() (line 1545 of /var/www/aaaa/www/includes/bootstrap.inc).
Comments
Comment #1
mschudders commenteda temp fix is to hook_submit the form and;:
So the error is produced because :
$form_state['values']['particulier_txt']The field is an array instead of an normal stringComment #2
thirdender commentedI don't know if this is an issue with the Media module. The last error is an error that can be related to the text_format text field. Without seeing the rest of the OP's code, it's hard to say.
Comment #3
hargobindI ran into the same problem, and I confirmed that it's not an issue with the media module ... well, at least not when your form has been coded properly.
Here's example code that implements a
system_settings_form()that causes this error:When the variable is empty, you see no errors. As soon as you save the form and the variable gets a value,
media.filter.incwill throw an error in_media_generate_tagMap()when it tries to use the value of$signature(which is an array) as a text string when it callspreg_match_all().Here is what your code SHOULD look like. Notice that '#default_value' and '#format' are using the respective keys of the $signature array.
The workaround provided by @Mschudders is incorrect because it does not store the '#format' of the field. So if a user chooses a different text format, it will be reset to the default one next time they visit the form. It's hard to determine whether this is an issue with Panopoly, or with custom code created by @Mschudders, so feel free to modify this issue and assign it to Panopoly if needs be.
Comment #4
hargobind