Problem: any validate and submit handlers added by
Steps to reproduce:
1. enable wysiwyg_filter module. Apply WYSIWYG filter to Filtered HTML format.
2. Enable eminline module and emvideo module. Apply embedded media filter to Filtered HTML format.
3. Configure this input format. Select changes for both emfield_filter and wysiwyg_filter. Submit.
4. Changes are saved for wysiwyg_filter but not eminline filter.
Source: In filter_admin_configure(), filter module uses array_merge() to merge filter forms from distinct modules providing filters.
$form = array_merge($form, $form_module);
This means that any common keys, e.g., #submit, #validate, declared by one module are overwritten by later modules.
Fix: use hook_form_alter() to add validate and submit handlers.
I'll post a patch.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | 746434-7-wysiwyg_filter-DRUPAL-6--1.patch | 881 bytes | nedjo |
| #3 | 746434-3.patch | 1.4 KB | nedjo |
| #1 | 746434-1.patch | 1.18 KB | nedjo |
Comments
Comment #1
nedjoPatch attached.
Comment #2
nedjoComment #3
nedjoWe can't append to the #submit array because we need to ensure this module's submit handler comes before system_settings_form_submit().
Patch updated.
Comment #4
duozerskThank you, nedjo.
Followed this thread. Indeed, the first patch was not that good - some options were saved as string variables (namely, ...valid_classes_..., ..._valid_ids_..., and ..._style_urls_...). The second patch fixes that and now the options are saved into variables as arrays (as it should have been).
Thanks
AndyB
Comment #5
kewlguy commentedsubscribing
Comment #6
markus_petrux commentedGood catch. Thanks for working on a fix, and sorry for the delay giving feedback in return.
Patch in #3 applied to CVS.
Comment #7
nedjoThanks Markus.
Now that I look at it again, I'm not sure why I didn't just use array_unshift(). It's a safe assumption that the #submit key is set, since the form would be broken without it.
Updated patch attached.
Comment #8
markus_petrux commentedI tend to use defensive code if it doesn't add too much overhead, but true, here we can count that core itself has already appended a submit handler if not already provided originally by the form owner.
Patch applied. Thanks again!