I have added a custom button which has an ajax callback with the following code to the user profile form.
$form['validate_2'] = array(
'#type' => 'button',
'#value' => t('validate 2'),
'#ajax' => array(
'callback' => 'example_validate',
'wrapper' => 'validate-settings',
'method' => 'replace'
),
'#name' => 'user_validate_2',
'#id' => 'user-validate-2',
'#weight' => 10
);
But when I click on it, it gives me ajax error in popup saying
An AJAX HTTP request terminated abnormally.
Debugging information follows.
Path: /system/ajax
StatusText: n/a
ResponseText:
( ! ) Fatal error: Call to undefined function user_profile_form_validate() in /includes/form.inc on line 1520
In my ajax callback I'm simply displaying the $form_state
array. Any idea what I'm doing wrong?
The form's own submit button is not with ajax.
function example_validate($form, &$form_state) {
dsm($form_state);
}