I am using Organic Groups. That module has a form where you add new members to a group. I would like to run additional validation on that form. I use hook_form_alter and can identify the form. I add a validate callback and verify its been added to the form array. Yet that function never runs. I don't know why.
function organization_control_form_alter($form, &$form_state, $form_id){
if($form_id == 'og_ui_add_users'){
dpm("Validation Added");
//This dpm displays.
$form["#validate"][] = 'organization_control_og_size_control_form_validate';
//I have also tried running my validate function first, like this
//array_unshift($form["#validate"],'organization_control_og_size_control_form_validate');
//I have also tried only running my validation, like this
//$form["#validate"] = array('organization_control_og_size_control_form_validate');
dpm("form");
dpm($form);
//This dpm shows the validate callback has been added.
}
}
function organization_control_og_size_control_form_validate($form, &$form_state){
dpm("Validation Started");
//This dpm NEVER shows
//hard code an error for testing
$subscriptionInfo['field_total_seats_value'] = 4;
dpm("Validation Run 2");
//This dpm NEVER shows
if($organzational_control_organization_size >= $subscriptionInfo['field_total_seats_value']){
dpm("ERROR");
//This dpm NEVER shows
form_set_error('edit-name', t('Your Organization has reached is current license size limit.'));
//This error is not displayed and the form submissions continues and succeeds.
}
else{
dpm("It thinks its Okay");
//This dpm NEVER shows
}
}