| Project: | FileField |
| Version: | 6.x-3.1 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (won't fix) |
| Issue tags: | ahah, form_alter, hook_form_alter |
Issue Summary
Hi,
I'm using hook_form_alter to alter a fieldfield and move into a wrapper #type => 'markup' form element. This wrapper is used to hide the filefield and other fields with haha when some value are selected in a taxonomy field.
It works when I'm not using ahah submission of the filefield, but not when using haha (when pushing the Upload). I looked up in filefield.module:filefield_js() i found out that
- hook_form_alter implementations are not invoked. I'm still new to Drupal, filefield and ahah but, according to Doing AHAH Correctly in Drupal 6,
drupal_process_form()anddrupal_rebuild_formshould be invoked, where filefield only callform_builder. - The filefield form element is fetched from the form using an un-alterable form path taking only fieldgroup and multigroups into accounts.
I can probably work around the second point by detecting that the MY_form_alter invocation is done in the context of the filefield ahah (arg(0) == 'fielfield' && arg(1) == 'ahah') and move the field back to its expected form path. But since the hook is not called, it couldn't not be done.
I'll probably try to patch filefield_js() myself, but maybe there is good reason to not call drupal_process_form() and drupal_rebuild_form like recommended.
Comments
#1
(add tags)
#2
Borrowing code from ahah_helper module, I came with the following patch which seems to work...
#3
I am quite interested in this as well. Any plans to get formal Drupal form processing in there at some point (particularly in the filefield_js function)?
#4
Updating issue title
#5
This approach introduces security problems by disabling #element_validate on elements, even though they are still processed. I'd suggest just using hook_elements() like FileField Sources and ImageField Extended do, which makes it so that you can move your FileFields around in the form (such as in Fieldsets) and not have them break.
#6
Subscribing, I need this functionality too.
#7
It's probably worth mentioning that while the patch in #2 does allow adding new fields to widget elements the elements are lost (at least in my case) if CCKs "Add another item" function is used to load another object.
For example:
#8
Per my notes in #5, this request is incorrect and you should use hook_elements() to modify FileField.