Skip to content

Instantly share code, notes, and snippets.

@segovia94
Created December 10, 2013 22:29
Show Gist options
  • Save segovia94/7901520 to your computer and use it in GitHub Desktop.
Save segovia94/7901520 to your computer and use it in GitHub Desktop.
// the required fields that we want to ignore
//$safe_fields = array('field_test2');
//just grab all fields in the second field group
$safe_fields = $form['#groups']['group_option2']->children;
// get a list of all errors
$errors = form_get_errors();
// this will clear Error msg queue
$messages = drupal_get_messages('error');
// clear all errors so we can add all of them back except the ones we are trying to clear
form_clear_error();
if (count($errors)) {
foreach ($errors as $field => $msg) {
$field_name = substr($field, 0, (strpos($field, '[') - 1));
if (!in_array($field_name, $safe_fields)) form_set_error($field, $msg);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment