phpdrupaldrupal-6drupal-fapi

Drupal Studs help me with my form_alter hook ( I am almost there)


So I think I am almost there conceptually but need some missing pointers.

Objective is to add a few more fields to the normal user registration form, style it a little, then submit it with storing the extra fields in a table.

This is what I have so far. Can someone give me the final nudge and get me going. Please help me. Also how do I apply some minor styling like aligning the new form fields ?

Thank you so much !!!!!!!!!

  function module_menu() {
$items = array();
$items['school/registration'] = array(
      'title' => 'Upgraded Registration Form',
      'page callback'    =>'module_school_register',
      'type' => MENU_CALLBACK
);

return $items; }//end of the function

function module_school_register(){ return drupal_get_form('form_school_register'); }//end of the function

function module_school_form_alter(&$form, $form_state, $form_id) {

dsm($form_id);

if ($form_id == 'user_registration_form') { // modify the "#submit" form property by prepending another submit handler array $form['#submit'] = array_merge( array('_module_registration_submit' => array()), $form['#submit'] );

} }

function _module_registration_submit($form_id, $form_values) { // store extra data in different table }

function module_registration_validate($form, &$form_state) { $error=0; //Validation stuff here, set $error to true if something went wrong, or however u want to do this. Completely up to u in how u set errors. if ($error) { form_set_error('new_field_name', 'AHH SOMETHING WRONG!'); } }


Solution

  • I suggest you have a look at content profile module before rolling your own solution.

    You define your a custom content type (node) for your school registration, add in you cck fields, and activate it as a content profile. On content profile settings, you then activate it on user registration form. Zero code !