Needs work
Project:
CTools Auto-modal
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
6 Jan 2012 at 12:22 UTC
Updated:
29 Jun 2012 at 08:33 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
wojtha commentedIts not possible at the moment, so this is a feature request.
Comment #2
wojtha commentedI've extended the CTools Automodals so now they knows how to handle submitted forms. You can try my patch here: #1420534-1: Consider a new hook - hook_ctools_automodal_paths() rather than using hook_menu()
Or just replace ctools_automodal_get_form() with this code:
Comment #3
douggreen commentedHere's the patch to just fix the bug.
Comment #4
wojtha commentedThis doesn't seem like a general fix.
Forms are usualy redirected using form_state[redirect] - this should be handled too imho.
Comment #5
douggreen commentedYou're right on both accounts, sorry, I was copying code from another module.
Comment #6
douggreen commentedComment #7
wojtha commented$form_state['destination'] should be $form_state['redirect']. And notice that $form_state['redirect'] can be both array or string.
Comment #8
wojtha commentedComment #9
wojtha commentedBetter title
Comment #10
xen commentedIf $form_state['redirect'] is an array, it is used as parameters to drupal_goto, which means that the second argument is options.
Added support for rebuilding forms, and cleaned up a bit.
Comment #11
wojtha commentedNice cleanup @Xen!
However, doesn't seem right to me.
In the drupal_redirect_form documentation is the following code:
So it should be:
list($path, $options) = $form_state['redirect'];(However in this case we still silently suppose that non-mandatory $options array is present.)
Comment #12
wojtha commentedComment #13
xen commentedYou're right, that was a thinko.
Well, if options isn't set, $options should just be empty... Though the manual doesn't say.
Comment #14
xen commentedOk, make that:
Then options is always set, and an array (as expected by ctools_ajax_command_redirect) per default.
Comment #15
xen commentedAnd patch...
Comment #16
rv0 commentedTrying to get this to work with forward.module (http://drupal.org/project/forward), but no luck so far.
Submit works, but I get a huge js error (200) afterwards.
When I add an extra submit function to the form, that has nothing but
exit();in it, I don't get the error (but nothing closes)Any ideas?
Comment #17
bdawg8569 commentedI am having an issue with submitting a form as well. I want the form to redirect, however, i don't want it to redirect to the same place each time. Inside of the form submit, i am making a call to a function that takes the form and determines if the person should go to one of two places. Is it possible to do this type of thing? If i try to change the form_state['redirect'] i get ajax errors.
Comment #18
wojtha commented@rv0 with the patch in #15 it should work. May be you can try my experimental build of this module, see #1420534-4: Consider a new hook - hook_ctools_automodal_paths() rather than using hook_menu()
@bdawg8569 are you getting Ajax errors with the patch in #15 or without?
Comment #19
rv0 commented@wojtha
I tried the experimental build, but it doesn't work on PHP <5.3 https://github.com/wojtha/ctools_automodal/issues/1
Will also retry #15 on a fresh install.
Comment #20
xen commented@rv0:
Does the menu item that you're modalling have 'page callback' => 'drupal_get_form'? Automodal doesn't work well with page callbacks that call drupal_get_form themselves.
Comment #21
wojtha commented@Xen good point
@rv0 if it is that case you can take some inspiration from #1450372: How to: How to handle two forms in one modal (unified login page). I've described there how to handle two forms in one modal window. For live example you can go to http://ecommera.com and click on "Register".
Comment #22
rv0 commentedthe menu item looks like this
The forward_page function looks like it hasn't changed since D6 as it has some legacy modalframe code in it.
it applies some logic and then returns a result of drupal_get_form
http://drupalcode.org/project/forward.git/blob_plain/HEAD:/forward.module
Comment #23
xen commentedThen it's really a separate issue. The code this issue deals with determines forms from the menu callback.
Whether there really is a general way of dealing with forms in page callbacks is the question.
Comment #24
agence web coheractio commentedHi,
I've tried patch #15 with a webform having confirmation message set a "No redirect (reload current page)".
The form submits correctly and I can see the throbber. However the confirmation message is not displayed in the modal window after the submission. It is displayed into the background window after a full page reload
Any idea?
Thanks
Laurent
Comment #25
wojtha commented@Laurent, you may try my fork of this module https://github.com/wojtha/ctools_automodal, there you can handle confirmation messages (details here: #1420534: Consider a new hook - hook_ctools_automodal_paths() rather than using hook_menu())