Friday, February 18, 2011

Drupal form_set_error: Set error in two fields and display error message once

When we face an issue for highlighting two fields with one validation message. Please do follow the below steps.

<?php
function <custom>_validate($form) {
form_set_error("<fieldname1>","Please check your entry");
form_set_error("<fieldname2>","Please check your entry");
array_pop($_SESSION['messages']['error']);
}
?>