i followed the handbook instructions for making a module settings page (http://drupal.org/node/82967)

however, no directions are provided for validating module settings.

can anyone tell me the canonical method of validating module settings, or suggest a module that i can use as a model?

thanks!

Comments

Jeff Burnz’s picture

Once you've defined the settings form you can hook into the form submission process with a validation function.

I've just been playing with the throttle module and there's a good example around line 166.

www.sitespring.eu

Stuart Greenfield’s picture

If your settings form were defined in modulename_admin_settings() then the validation function would go in modulename_admin_settings_validate($form_id, $form_values)

You can then do checks, set errors with form_set_error and so on.

The validation function doesn't need to return anything - if you set an error the form is re-presented for completion.

It took me a while to get my head round this when I started out!
________

Just five more minutes...

www.stuartandnicola.com