Form api custom validation function doesn't work I'm trying to reuse the login form in my own form. So far so good, everything is populated and shown properly. Now I want to use my validation functions to validate some data, so I tried to add them:

$userLogin = drupal_get_form('user_login');
array_unshift($userLogin['#validate'], 'MY_UBERLEAD_FUNC_validate');
$form['selfservice_ad_tabs']['tab_3']['login'] = $userLogin;


Printing the form shows that the function is in the proper place, but it was not invoked when expected.

I tried several other methods:

$userLogin['actions']['submit']['#validate'][] = 'MY_UBERLEAD_FUNC_validate';


also removing all validation handlers and leaving just mine, but those didn't work either.

Can somebody point what i am doing wrong or explain how i can reuse existing form into my custom form using my validation functions.

Thanks in advance!
I think that if you use drupal_get_form() you can't alter the form because the form will be already built, cached and all the processing done.

Try this instead.

$form_init = array();
$userLogin = user_login_block($form_init);

array_unshift($userLogin['#validate'], 'MY_UBERLEAD_FUNC_validate');
$form['selfservice_ad_tabs']['tab_3']['login'] = $userLogin;