By firebus on
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
Once you've defined the
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
Pimp your Drupal 8 Toolbar - make it badass.
Adaptivetheme - theming system for people who don't code.
Example...
If your settings form were defined in
modulename_admin_settings()then the validation function would go inmodulename_admin_settings_validate($form_id, $form_values)You can then do checks, set errors with
form_set_errorand 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