If a form field has the name 'edit'; e.g.:
$form['edit'] = array(
'#type' => 'textfield',
...
);
then upon submitting the form we will be redirected to a "strange" URL: a URL which is the first letter typed into that form field. For example, if we type "rolex" into the field, then, after clicking the submit button, we will be redirected to http://example.com/r.
That's becaue drupal_goto(), which is used by FAPI, has the folowing code:
[...] if (isset($_REQUEST['edit']['destination'])) {
This condition will evaluate to TRUE. That's how string subscripts are handled in PHP. Another example:
$a['edit'] = 'rolex';
// the following statement prints 'r'
print $a['edit']['destination'];
(Bug discovered while helping a user in the fourm.)
Comments
Comment #1
Crossfeed commentedsame problem in D6, a form and all of its hooks can't be named edit. If they are called something with edit,
For example: modul_edit_form_submit() will redirect to the same "strange" url als reported above
changing the forms name to editor solves all failures
Comment #2
tamerzg commentedI just spent an hour figuring why my form is not redirecting properly. It ended up because one of the form fields was named 'edit'.
Comment #3
damien tournoud commentedSomeone wants to take a shot at rolling a patch? We need to add a is_array() here.
Comment #4
tamerzg commentedYes, is_array should fix the problem.
Here is a patch.
--------------
Tamer Zoubi
Freelancer, Drupalist
Skype: tamerzg2005
Comment #5
tamerzg commentedComment #6
albert volkman commentedD6 backport.
Comment #8
albert volkman commentedAh, we need to check for the existence of $_REQUEST['edit'] first.