Hi,

Please look at following code:

function mymodule_menu() {
    $items = array();
    $items['user/register/%'] = array
    ( 
        'page callback' => 'drupal_get_form',  
        'page arguments' => array('mymodule_user_register'),
        'access arguments' => array('access content'),
        'type' => MENU_CALLBACK,
    );  
      
    return $items;
} 

function mymodule_user_register(&$form_state, $doctor) {
   $form['email'] = array(
    '#type' => 'textfield',
    '#title' => '',
    '#size' => '20',
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Subscribe',
  );
  return $form;
}

The issue is that this hook is not returning any form.

Please tell me what i am doing wrong here.

Regards,
Kuldeep.

Comments

nevets’s picture

It appears you are trying to override the path used for registration which I believe will fail because the path is in use.

jaypan’s picture

Well, he's registering a sub-path, so it looks like it should be fine.

Kuldeep - what path are you accessing?

Contact me to contract me for D7 -> D10/11 migrations.

kuldeepkaundal’s picture

Well my path is user/register/certain_code

like:

user/register/10003445

nevets’s picture

It could be because this declaration

function mymodule_user_register(&$form_state, $doctor)

says the function expects a second argument ($doctor) but none is passed in and is likely to cause an error.

jaypan’s picture

Good point. To fix that, this:

        'page arguments' => array('mymodule_user_register'),

Should be changed to this:

        'page arguments' => array('mymodule_user_register', 1),

Contact me to contract me for D7 -> D10/11 migrations.

kuldeepkaundal’s picture

Thanks for reply, but, i don't really need any parameters, so, even if i write this:

function mymodule_user_register(){

form code

}

I still can't see any form!

jaypan’s picture

You have told the function to expect a variable called $doctor, and you aren't sending the function that variable. This will cause you problems. You can call it anywhere, but as long as you don't pass it $doctor, it's not going to work.

Contact me to contract me for D7 -> D10/11 migrations.

kuldeepkaundal’s picture

Ok, the form is working on default drupal installation, since i am trying to add this form on a drupal website already built, it must be related to some configuration on that website, can someone please suggest me what that can be?

jaypan’s picture

Yes, it's that you aren't passing the $doctor variable to your form.

Contact me to contract me for D7 -> D10/11 migrations.

kuldeepkaundal’s picture

Oh, comeon, i already told, same thing is working in default drupal installatio, with no changes required, its only this website that is already setup and i need to add this form is not showing form, i guess its a configuration issue now not related to coding, since same code works on other default installation.

Yes, as per ur suggestion, i removed $doctor and changes the function to:

function web_service_registration_form() {

}
Any suggestions?

Anonymous’s picture

Have you cleared your caches since you changed the function name? The menu router table will need to be rebuilt with the new function name