i just had a look at this flexinode issue and discovered that the formapi requires a drupal_goto after each submited form. (due to this patch) imho this isn't really useful...

i've attached a possible solution by changing the formapi behaviour. this fixes the flexinode issue and also this issue for me.

Comments

chx’s picture

Status: Active » Needs review
StatusFileSize
new1.36 KB

Well, yes. I also simplified the goto logic a little bit.

chx’s picture

StatusFileSize
new1.89 KB

We should be very cautious here, because we need to discern between empty string (home page) and nothing (aka NULL). After this (needed) patch is committed you can simply return nothing and not get a goto.

chx’s picture

Assigned: Unassigned » chx
chx’s picture

Title: formapi requires drupal_goto on submit » fix locale and admin/node search form goto bugs
StatusFileSize
new4.3 KB
chx’s picture

StatusFileSize
new4.59 KB
chx’s picture

StatusFileSize
new4.66 KB
chx’s picture

I marked a few issues a duplicate to point here. While technically this is the duplicate but the patch I started from was here. The others was just talk.

chx’s picture

StatusFileSize
new4.56 KB
fago’s picture

StatusFileSize
new5.56 KB

your patch didn't work for me.
i just cleaned it up (typo) and fixed it - further i changed the default for #redirect from '' to NULL. so that the above mentioned goto() issues are fixed, but the locale string search stilll doesn't work - probably this is another issue. chx's locale.inc changes are still included in this patch

chx’s picture

StatusFileSize
new4.57 KB

I do not agree with removing the default empty goto. The typo is fixed, sorry.

fago’s picture

sry, if I got this wrong - but imho setting a goto to the frontpage as default redirect isn't really useful?!

chx’s picture

Status: Needs review » Reviewed & tested by the community

IMO it is useful. That's always applicable even after deleting something and you can set REQUEST[destination] or REQUEST[edit][destination] before.

morbus iff’s picture

fago: whether it's useful or not, it's the default behavior of existing core, and should not be changed. We're trying to minimize changes and "features" to get ready for an RC, so the patches should be as minimalistic and bugfix-only as possible. So +1 to RTC'd #10, and fago, if you really want no default (which, honestly, I do too), you should consider opening a new "normal" "feature request" so that it can be attended to for 4.8.

chx’s picture

Status: Reviewed & tested by the community » Needs work

drumm votes on FALSE instead of NULL, he is right, but I have some problem w/ testing that patch. Stay tuned.

Ariel T Glenn’s picture

fago noted:

the locale string search stilll doesn't work - probably this is another issue.

Yes. Having hit the drupal_goto() issue in both variations while I am writing a module, I recognize the locale module issue as this:

  • generate a form
  • user submits
  • you want to take the output of the form and generate a new form with the results...

With the existing drupal_get_form() you cannot do this, because a call to drupal_get_form() to generate the new form will check $_POST['edit'] and see that stuff is in there. It will then go through the validate/submit/drupal_goto branch instead of the form generation code you want.

This is distinct from the user module issue described here by everyone else, and so the locale module bug really shouldn't be marked as a dup of this one.

To fix this bug, I suggest that the caller needs to be able to tell drupal_get_form() that it should really really not go through the validation/submit branch even if there is stuff in $_POST; say, an extra parameter to drupal_get_form(). If the extra arg is not passed, the default behavior should apply.

In addition, for the current patch, the submit/validate branch should return (an empty value, maybe) rather than falling through to the form generation code if there is no goto. Then form generation will not be required in order to do other things after validation/submit than a redirect.

Someone in the comments on issue 49123 tried setting $_POST['edit'] to NULL before _locale_string_seek_form(); and got the correct output, which shows that avoiding the validation/submit branch altogether is the appropriate behavior for these sorts of forms generated from results of other forms.

Unless folks think of a better way to handle this...

chx’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new4.46 KB

We are good to go. If you do not want to redirect you set #redirect to FALSE.

For the above, slightly off topic lengthy comment, use a button not a submit and you'll be good.

chx’s picture

If you do not want to redirect you set #redirect to FALSE or return FALSE in submit.

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD. Thanks.
(Beh, more form attributes.)

Anonymous’s picture

Status: Fixed » Closed (fixed)
ultraBoy’s picture

Version: » 4.6.6

Please! mention this "['#redirect'] = FALSE" possibility, 'cause I spent about 10Hrs to identify my problem with redirection and then to find a solution.