Firstly, I altered the Forgot Password Form in my template.php and added the #ajax property:
// Ajaxifying the form
$form['actions']['submit']['#ajax'] = array(
'callback' => 'themename_user_pass_form_ajax_callback',
'wrapper' => 'user-pass',
'method' => 'replace',
'effect' => 'fade',
);
Then I created the ajax callback function:
function themename_user_pass_form_ajax_callback($form, &$form_state){
module_load_include('inc', 'user', 'user.pages');
return $form;
}
The form works fine in /user/password page and the ajax works too.
I want the form to appear in the front page, So in my page--front.tpl.php I added the following:
<?php
module_load_include('inc', 'user', 'user.pages');
$user_pass = drupal_get_form('user_pass');
print drupal_render($user_pass);
?>
The form appears and when submitting returns with js alert
An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: /system/ajax StatusText: Internal Server Error ResponseText: Memory used at: devel_boot()=3.43 MB, devel_shutdown()=32.2 MB, PHP peak=32.25 MB.
Note: The ResponseText is from devel.
In my php_error log file I found this:
PHP Fatal error: Call to undefined function user_pass_validate() in /www/drupal/includes/form.inc on line 1464
The user_pass_validate()
is not declared maybe module_load_include('inc', 'user', 'user.pages');
is not working with the ajax call?