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

Sheryl (Permutations Software) sheryl at permutations.com
Wed Jan 21 19:55:35 UTC 2009


Matt Chapman wrote:
-------------------------------------------
I might suggest moving this code into a hook_validate and hook_submit as 
a possible approach, eg:

function your_form_name_validate($form, $form_state) {
  //This assumes that there is a submit buttons called 'submit'. Adapt 
as per your form.
  if (!_phpfreechat_check_install()) {
    form_set_error('submit', _phpfreechat_not_found());
  }
  if (!_phpfreechat_check_files()) {
    form_set_error('submit', t('Unable to create data folders for 
phpfreechat.'));
  }

}

function your_form_name_submit($form, $form_state) {
    _phpfreechat_clear_cache();
    _phpfreechat_clear_cookies();
}
-------------------------------------------

What you have here doesn't jive with what I'm seeing in the docs, so I'm
confused. According to the links below, hook_validate does not take
$form_state as a parameter:

http://drupal.org/node/241364
http://api.drupal.org/api/function/hook_validate

Also, you say to name the function "myformname_validate", but I don't see a
form name set anywhere. Where do I get the form name?

Thanks.

	- Sheryl




More information about the development mailing list