[development] converting a module from Drupal 5 to Drupal 6

Jakob Petsovits jpetso at gmx.at
Wed Jan 21 19:09:03 UTC 2009


On Wednesday, 21. January 2009, Steven Jones wrote:
> Use form_set_error
> (http://api.drupal.org/api/function/form_set_error/6) and call it with
> the first parameter as 'NULL', then the error will be set on the form
> as a whole, not an individual element.

form_set_error() encloses the error assignment in this if-condition:

if (isset($name) && !isset($form[$name])) {
  (...set the form error...)
}

which means when the first parameter ($name) is NULL then no error will be set.
It seems you need to set the error for any of your form elements, presumably 
the submit button in your case was used because the submit button was the only 
element that's remotely suitable for that error.

You might use the actual submit button as error target in Drupal 6 (...I think 
that should work) by doing a form_set_error('mybuttonname', t('message')) or - 
alternatively, same effect - form_error($form['mybuttonname'], t('message')).

Cheers,
  Jakob



More information about the development mailing list