Hi all. I want to modify the user registration in 2+ steps or better: I want that the form that new user use for registration (/user/register) is splitted in 2+ page. This because via profile module I have added 15 new field.
I know that I can write a form splitted in 2 page (I read "Pro Drupal Development), but I don't want to create the register form from zero. I have tried to delete the $form['#submit'] value via hook_form() but with no results. Is there a way to do this without create a new module for user_register ?
Tnx.
On Thu, 03 Jan 2008 17:17:51 +0100 Davide Michel 'ZioBudda' Morelli michel@ziobudda.net wrote:
Hi all. I want to modify the user registration in 2+ steps or better: I want that the form that new user use for registration (/user/register) is splitted in 2+ page. This because via profile module I have added 15 new field.
I know that I can write a form splitted in 2 page (I read "Pro Drupal Development), but I don't want to create the register form from zero. I have tried to delete the $form['#submit'] value via hook_form() but with no results. Is there a way to do this without create a new module for user_register ?
What about alter_form + a redirect to another piece of registration? But well no luck if you plan to still use profile.module and avoid to write your own module.
My main concern about approaching this problem this way would be to deal with core in a way that in the future may not be considered kosher or break up once you add other modules etc...
Ivan Sergio Borgonovo ha scritto:
On Thu, 03 Jan 2008 17:17:51 +0100 Davide Michel 'ZioBudda' Morelli michel@ziobudda.net wrote:
Hi all. I want to modify the user registration in 2+ steps or better: I want that the form that new user use for registration (/user/register) is splitted in 2+ page. This because via profile module I have added 15 new field.
I know that I can write a form splitted in 2 page (I read "Pro Drupal Development), but I don't want to create the register form from zero. I have tried to delete the $form['#submit'] value via hook_form() but with no results. Is there a way to do this without create a new module for user_register ?
What about alter_form + a redirect to another piece of registration?
It does not work. I don't know why, but user_register function is called with or without other "validation".
But well no luck if you plan to still use profile.module and avoid to write your own module.
Why this ? If I use profile.module I use core Drupal with a form/admin page where I can insert new item without modify php code lines (if I use my module).
My main concern about approaching this problem this way would be to deal with core in a way that in the future may not be considered kosher or break up once you add other modules etc...
However this is my alter_form function:
function mw_ur_form_alter($form_id,&$form) { if ($form_id == 'user_register') { //print_r($form); if (!isset($form['#post']['step'])) { $form['#multistep'] = TRUE; $form['#tree'] = TRUE; $form['#redirect'] = FALSE; $form['step'] = array ( '#type' => 'hidden', '#value' => 1 ); unset($form['Informazioni personali']); $form['submit'] = array( '#value' => 'next', '#type' => 'submit', '#weight' => 30 ); } else { /* $form['#multistep'] = TRUE; $form['#tree'] = TRUE; $form['#redirect'] = FALSE; $form['account']['name']['#default_value'] = $form['#post']['account']['name']; $form['account']['mail']['#default_value'] = $form['#post']['account']['mail']; */ unset ($form['Residenza']); } /** * only for test */ /*foreach($form as $key => $value) { print("-".$key."-<br>"); }*/
} }
Now my problem is this: I compile the "username and mail field" (only items required) then I click on the "next" button and I get the same page (ok, this is correct) but with username and email field empty and an error messagge that say me that username and mail filed must be non-empty. If I see the $form values via print_r() I can see that the $form['post'] are not empty (see my else code).
M.
Ivan Sergio Borgonovo ha scritto:
On Thu, 03 Jan 2008 17:17:51 +0100 Davide Michel 'ZioBudda' Morelli michel@ziobudda.net wrote:
Hi all. I want to modify the user registration in 2+ steps or better: I want that the form that new user use for registration (/user/register) is splitted in 2+ page. This because via profile module I have added 15 new field.
I know that I can write a form splitted in 2 page (I read "Pro Drupal Development), but I don't want to create the register form from zero. I have tried to delete the $form['#submit'] value via hook_form() but with no results. Is there a way to do this without create a new module for user_register ?
What about alter_form + a redirect to another piece of registration? But well no luck if you plan to still use profile.module and avoid to write your own module.
I have tried the "personal module", too. But there is a problem with the possibile user error (like email present into DB) that are present in one o more step back. How can I know in which step is the error ?
This is from my code (this function create the form):
function mw_ur_register2($form_values = NULL) { var_dump($form_values); echo "aaa"; $form['#multistep'] = TRUE;
.... }
Note the "var_dump($form_values)": if I insert a wrong field it say me that $forn_values is "NULL" however. So I have concluded that Drupal create error messagge and alter form after that my function is called (and this is correct because my function create the original form). So split the user register in 2 page it's impossible. I think...
M.