In switching from custom AHAH code in CCK widget, to using ahah_helper, I found a number of things that needed to be done, but weren't.
- node/node.pages.inc needs to be loaded to correctly rebuild the node form
- to have access to the $nodes fields, node_form_submit_build_node() needs to be run
- in order that taxonomy doesn't reset after a page reload, we need to run taxonomy_preview_terms()
- in order that the redirect works after final submit, we need to clear the $form_state['storage']
Most of these changes are only activated if ahah_helper sees that it is running on the node form. It would be awesome if this (and many other useful patches from other people in the Issue queue) were accepted, as my ahah_helper module is quickly becoming quite different than the last release.
Thanks!
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | ahah_helper-node-form.patch | 2.1 KB | dsnopek |
| ahah_helper-node-form.patch | 1.95 KB | dsnopek |
Comments
Comment #1
aaronbaumanFrom a brief test, the "save" button works fine, but the user is not redirected to the confirm delete page when clicking the delete button.
Do you use a particular CCK / AHAH Helper widget that you can post to standardize testing / reviewing?
Comment #2
dsnopek@aaronbauman: You are right about the "Delete" button not working! I hadn't noticed that originally and it was broken in my application too. Attached is an updated patch that fixes this problem.
Comment #3
cristhian commentedDoes this work in cck fields using form_after_build?
Comment #4
aaronbaumanThis patch changes the way form submits are processed with the #submit property.
#after_build shouldn't have anything to do with it.
Comment #5
cristhian commentedI have used cck fields with ahah_helper, and it submits well without adding this patch..
I made a little module that allowed me to attach ahah behavior to CCK Widgets (like textfield and select), but I had to use #after_build in order to do that, because in the hook_form_alter those widgets aren't created yet.
That's what I meant.
Comment #6
hanoii@Cristhian,
I am about two work on a cck widget that I need it to have AHAH. I am about to start, read the docs, look at the demo and was about to start playing with it. If you can explain to me what you've done with your CCK widget and the #after_build, as well as, if possible, to share that module, that will help me a lot. If not just some hints of pointers would be great.
a.=
Comment #7
aaronbaumanCristhian:
Are you saying you do not have the issue reported here:
#513322: Not being redirected after node creation or edit
?
You must have built your own redirection functionality or otherwise manipulated the form_state in order to work around that bug...
Comment #8
FranciscoLuz commentedThis patch worked just fine for me. Thank you dsnopek.
Comment #9
aaronbaumanComment #11
marthinal commented@dsnopek Thanks very much for the patch.
Comment #12
marthinal commented@dsnopek Please if you have time can you explain to me why (in the patch #3):
function ahah_helper_real_submit($form, &$form_state) {
// i dont understand whyi need to unset $form_state['storage']
unset($form_state['storage']);
}
Im triying to understand it.
Thanks for your time .
Comment #13
gbernier commented@marthinal
He's most likely unsetting the form_state['storage'] to ensure the form will do the redirects. Deep in the form API there is a if statement when checks to see if form_state["storage"] is populated and if it is it will not do the form_state["redirect"] because it might mean it's a multi-step form.
This is just my best guess as I've had to manually clear the form_state["storage"] on my submit functions using AHAH helper
Comment #14
marthinal commented@gbernier :
Ok thanks for your explanation.It helped to me understand why .
Thanks for your time ;)
Comment #15
nguyenpnb commentedThank you very much. This patch worked just fine ^^
Comment #17
hadsie commentedThis patch works for me on 6.x-2.1 as well. Thanks @dsnopek!
Comment #18
hadsie commentedComment #19
rconstantine commentedI tried modifying my module to use ahah_helper after applying this patch, but perhaps I'm doing something wrong. I'm working on a custom CCK module with multiple sub-fields, similar to my cck_fullname module. The difference this time is that one select field needs to control another.
Has anyone managed to create a multi-field CCK field module using AHAH_helper? Please share how you did it if so. I would imagine that some of the implications of CCK fields being on a node form apply, right? I have read most or all of the posts in this issue queue regarding that, trying several things with no luck.
What is happening now is that when I change the select, the target element disappears and is replaced with some dsm calls I am making for debug purposes.
The demo module creates a hidden submit field, which, since the 'first' submit button is called when a select is changed, gets fired off. In my case, I'm adding this button via form_alter. Is that not the right place? Do I need to give things some '#weight'?
Help!
Comment #21
rconstantine commentedI worked it all out. The only remaining issue I have is that when BOTH jQuery update AND core upload attachments are active for a given content type, the AHAH behavior doesn't work. Very strange. And that was very hard to figure out. But I have duplicated it on a clean site and had it confirmed by a third party. I'm not sure which module is to blame.
Since my needs actually don't include using both jQuery update and attachments AND changing the country all on one content type, I can live with this, but I'm sure if I release the module, people will have issues with that. But maybe with more eyes looking at it, someone will figure out what is wrong - although the issue may not be with my code at all, but with one of these other modules.
Comment #22
Rok Žlender commentedCommitted thanks.
Comment #23
Rok Žlender commentedComment #24
dsnopekWow, thanks Rok for finally committing this! I actually had to port my code away from ahah_helper when I started releasing my code publicly, because my version of ahah_helper had become sooo different from the upstream one and I couldn't expect people just wanting to use my module to apply 2-3 patchs to ahah_helper. I hope you get around to applying lots of the other wonderful patches from other people in the issue queue!
Best regards,
David.