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

Sheryl (Permutations Software) sheryl at permutations.com
Wed Jan 21 21:38:51 UTC 2009


But (on investigation) it's still the totally wrong function for the job.
The code belongs where it is. I just need to update the syntax. 


-----Original Message-----
From: Sheryl (Permutations Software) [mailto:sheryl at permutations.com] 
Sent: Wednesday, January 21, 2009 4:29 PM
To: 'development at drupal.org'
Subject: RE: [development] converting a module from Drupal 5 to Drupal 6

Apparently the function Matt was talking about is not hook_validate, but
_form_validate. That still doesn't have exactly the parameters he showed,
but $form_state is one of them.

http://api.drupal.org/api/function/_form_validate/6


-----Original Message-----
From: development-bounces at drupal.org [mailto:development-bounces at drupal.org]
On Behalf Of Sheryl (Permutations Software)
Sent: Wednesday, January 21, 2009 2:56 PM
To: development at drupal.org
Subject: Re: [development] converting a module from Drupal 5 to Drupal 6

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