I want to take an argument from the URL, ie: http://localhost/?q=node/add/retailer/12345.
And be able to use 12345 in the retailer_form_alter hook.
Can this be done?
Basically if this argument is not provided I want to display a message instead of the form?
Any help would be appreciated.
Cheers

Comments

nevets’s picture

Using the arg() function; node is arg(0), add is arg(1), retailer is arg(2) and 12345 would be arg(3). So you can write code something like this

$retailer = arg(3);

if ( ! $retailer || ! is_numeric($retailer) ) {
  // Argument is missing
  // Want to display an error, can not do that directly
  // with the way the node module builds the form
  // Instead we will goto a path defined in our menu hook
  drupal_goto("some valid path that will display the error");
}

// Build the form as usual
styro’s picture