There seems to be an old issue about this: https://drupal.org/node/477832

It seems that this doesn't work again, because node_form_submit() executes all the other submit handlers and sets the redirect argument after that, which seems to remove the settings set in modalframe_close_dialog(). To me it seems that an easy fix for this is not possible and I seem to be unable to find any kind of workaround for this. Is it even possible to have this working or should I just give up?

P.S. It might of course be that the node form handling hasn't been changed in any way since the fix and that I'm just making some other mistake; I sure hope so :-)

Comments

markus_petrux’s picture

Category: bug » support
Status: Active » Postponed (maintainer needs more info)

Have you tried attaching your submit callback to $form['buttons']['submit']['#submit'] ? If that does not work, then there may be some other module doing something here...

I know it works. The Node Relationships module uses it with no troubles (browse its code and search for "noderelationships_child_node_form_submit").

zeip’s picture

Yes, that indeed did work, as I also found out last night. It seems that this is not done automagically; perhaps it should (for example in the child_js function), or at least documented, if it isn't yet (I didn't find it.)

markus_petrux’s picture

Component: Code » Documentation
Category: support » feature
Status: Postponed (maintainer needs more info) » Needs work

I have not documented this because it's a particular case with the node form. Modal Frame method works. The problem is that the node module breaks the normal form processing flow. From my POV, this is one of those things that one should find by itself when using this API. It's not a feature of the API itself. Related, but not part of.

I wrote a page inthe handbooks for this API, and it can be found here:

http://drupal.org/node/700752

That's a page that can be edited by anyone, or maybe child pages can be created to enhance the basic documentation with this kind of experiences.

james.williams’s picture

In your custom submission handler that calls modalframe_close_dialog(), you might want to also have: $form_state['redirect'] = FALSE;

It didn't work for me without that.

SebCorbin’s picture

use $form['#redirect'] to redirect to page after submit

colorado’s picture

I was having this problem too, and figured out this:

http://drupal.org/project/save_edit module also causes this problem, when any of the buttons are displayed on the node form and the node form is displayed in the modal window.

gaëlg’s picture

For me it only worked in these conditions:

  • submit handler is added to the button ($form['buttons']['submit']['#submit'][] = 'my_closing_submit')
  • submit handler contains the following instructions in this order :
    $form_state['redirect'] = FALSE;
    modalframe_close_dialog();
    modalframe_child_js();
dsnopek’s picture

Issue summary: View changes
Status: Needs work » Fixed

Lots of good solutions to this problem given here. Closing.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.