[development] Advanced forms api question (#submit and #programmed)
Dave Cohen
drupal at dave-cohen.com
Thu Mar 1 04:15:37 UTC 2007
I'm trying to provide a patch for an issue I recently submitted
<http://drupal.org/node/123702>. I'm having trouble grokking some forms API
intricacies and I'm sure someone on this list can help.
Briefly, I'm trying to customize the update.php form using hook_form_alter().
Unfortunately update.php does not handle its form the normal way. Normally,
a form is created by calling drupal_get_form() and also processed by calling
drupal_get_form(). Update.php does not do this. My first question is why
not? But that is a bit off topic.
Because update.php calls drupal_get_form() only when displaying the form and
not when processing it, changes made (in my hook_form_alter) to
$form['#submit'] have no effect. That is, there is no way to have my custom
submit handler called when the form is submitted.
So, I've added a call to drupal_get_form in my copy of update.php, in the
update_update_page method. This does what I want, in that my #submit handler
is called. But there is an unwanted side-effect, which is the forms code
then redirects the browser. So I never get to the update.php progress page.
So it seems I cannot add my own handler and also have update.php do its
handling.
I poured through the forms code looking for where (and why) it does the
redirecting. There is a mysterious $form['#programmed'] variable which seems
to control this, but I can't figure out what that variable is really supposed
to be about, or where it's supposed to be set.
I feel like I'm close to solving my problem. But I could be going down the
wrong road. Or perhaps there is a much simpler solution. So I come here for
advice. Any help is really appreciated. Thanks,
-Dave
More information about the development
mailing list