List Info

Thread: Drupal 6.x FormAPI: validate and submit properties




Drupal 6.x FormAPI: validate and submit properties
country flaguser name
United States
2008-02-16 13:55:30
Hard at work trying to upgrade my modules to 6.x.  Looked at the Drupal 5.x to 6.x FormAPI changes here: http://drupal.org/node/144132

Particularly this regarding the validate and submit properties: http://drupal.org/node/144132#custom-params

In Drupal 5.x, I've been using this format:

<?php
function og_user_roles_form_alter($form_id, &$form) {
   ; &nbsp; &nbsp;
$form['og_user_roles_regcode_gid']['og_user_roles_regcoderole_value_' . $gid] = array(
&nbsp;   ; &nbsp; &nbsp; 
'#type' => 'select',
   ; &nbsp; &nbsp; &nbsp;
'#title' => t('Role to assign'),
 ; &nbsp; &nbsp; &nbsp; &nbsp;
'#options' => $roles,
   ; &nbsp; &nbsp; &nbsp;
'#default_value' => variable_get('og_user_roles_regcoderole_value_' . $gid, 0),
 ; &nbsp; &nbsp; &nbsp; &nbsp;
'#description' => t('Select the role you wish to use as the "registration code group role" for every new subscriber who subscribes to this group using one of the registration codes above.'),
 ; &nbsp; &nbsp; &nbsp; &nbsp; ); &nbsp; &nbsp; 
 &nbsp;   ; &nbsp;
$form['#validate'] += array('og_user_roles_regcode_form_validate' => array($form_id, &$form)); &nbsp;   ; &nbsp; &nbsp;
 &nbsp;   ; &nbsp;
$form['#submit'] += array('og_user_roles_regcode_form_submit' => array($form_id, &$form)); &nbsp;   ; &nbsp; &nbsp;
 &nbsp;   ; }
?>

My question is: How do I write the #validate and #submit properties for the above in Drupal 6.x? My example above does not look like the ones used here: http://drupal.org/node/144132#custom-params

So, would this be correct in Drupal 6.x?:

<?php
function og_user_roles_form_alter(&$form, &$form_state, $form_id) {
   ; &nbsp; &nbsp;
$form['og_user_roles_regcode_gid']['og_user_roles_regcoderole_value_' . $gid] = array(
&nbsp;   ; &nbsp; &nbsp; 
'#type' => 'select',
   ; &nbsp; &nbsp; &nbsp;
'#title' => t('Role to assign'),
 ; &nbsp; &nbsp; &nbsp; &nbsp;
'#options' => $roles,
   ; &nbsp; &nbsp; &nbsp;
'#default_value' => variable_get('og_user_roles_regcoderole_value_' . $gid, 0),
 ; &nbsp; &nbsp; &nbsp; &nbsp;
'#description' => t('Select the role you wish to use as the "registration code group role" for every new subscriber who subscribes to this group using one of the registration codes above.'),
 ; &nbsp; &nbsp; &nbsp; &nbsp; ); &nbsp; &nbsp; 
 &nbsp;   ; &nbsp;
$form['#validate'][] = 'og_user_roles_regcode_form_validate'; &nbsp; &nbsp; &nbsp;   ;
 &nbsp;   ; &nbsp;
$form['#submit'][] = 'og_user_roles_regcode_form_submit'; &nbsp; &nbsp; &nbsp;   ;
 &nbsp;   ; }
?>

Thanks for any information provided.

-ron
-- 
Ron Parker
Software Creations               http://www.scbbs.com
Self-Administration Web Site     http://saw.scbbs.com
SDSS Subscription Mgmt Service   http://sdss.scbbs.com
Central Ave Dance Ensemble       http://www.centralavedance.com

R & B Salsa                      http://www.randbsalsa.com
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )