Hello all,
I am very new to drupal, so don't be to hard on me if there is some stupid mistake in my code... ;)
Here is the scenario, i am developing my own module for user registration, so far so good
i managed to create a block with a form and make some validations of the fields when i click
the submit button.
Now what i want spice things up by adding some AHAH effects. My goal is that when the user clicks
on the register (submit) button, the form will fade out, a throbber will show up while the registration
process happen in the background, and when its done, a message will show up with something like
"registration done, bla bla bla".
my module is called "dctv_user_registration", here are the functions i created:
function dctv_user_registration_menu(){
$items['dctv_user_registration/js'] = array(
'page callback' => 'dctv_user_registration_js',
'access arguments' => array('access content'), //not sure what to use here...
'type' => MENU_CALLBACK
);
return $items;
}
function dctv_user_registration_js(){
return drupal_json(array(
'status' => TRUE,
'data' => "YP YP YO"
));
}
function dctv_user_registration_form() {
//define first name
$form['dctv_user_registration_first_name'] = array(
'#type' => 'textfield',
'#title' => t('First name'),
'#required' => TRUE
);
//...
//rest of the fields...
//...
//define the submit function.
$form['dctv_user_registration_submit'] = array(
'#type' => 'submit',
'#value' => t('Register'),
'#weight' => 10,
'#submit' => array('dctv_user_registration_form_submit'),
'#ahaha' => array(
'event' => 'click',
'path' => 'dctv_user_registration/js',
'wrapper' => 'block-dctv-user-registration',
'method' => 'replace',
'effect' => 'fade',
'progress' => array(
'type' => 'bar',
'message' => t('Please wait...')
)
)
);
return $form;
}
For testing purpose my validate and submit functions are empty so no point in listing them here...
Now the problem is, when i click the submit button, nothing happens, except that the form gets submitted
and the validate and submit functions are called.
What am i doing wrong? Should i be using a different approach?
Thanks in advance!