form api

drupal_execute Gotcha In Drupal 6.x

Many of you are probably familiar with drupal_execute(). However, those familiar with it from Drupal 5.x days will have to watch a new feature in Drupal 6.x.

Here's an example of an item in a hook_menu() implementation in the Taxonomy module for Drupal 6.x:

<?php
$items['admin/content/taxonomy/add/vocabulary'] = array(
'title' => 'Add vocabulary',
'page callback' => 'drupal_get_form',
'page arguments' => array('taxonomy_form_vocabulary'),

Form Redirection: A Special Case

Most of you are probably familiar with using the Form API (either via hook_form_alter or when building your own form) to set the destination a user is sent to after submitting a form.

<?php
function mymodule_form_alter($form_id, &$form) {
  if (
$form_id == 'page_node_form') {
   
$form['#redirect'] = 'my/new/page';
  }
}
?>

This usually works, but today I came across a special case.

What if you want to redirect users back to the referring page after they submit a new node? Sounds simple enough, right? You'd probably do something like this:

<?php

Syndicate content