I am using node gallery module.While creating an album, when the user enters duplicate name then error message is displayed as
This form requires that the fields Album name, Author are a unique combination. The specified values are already used.
I want to change this error message for duplicate album name. I have created a hook for this.
function hook_form_alter(&$form, &$form_state, $form_id) {
if ('NODE form id' == $form_id) {
$form['#validate'][0] = 'my_custom_validate';
}
}
function my_custom_validate(&$form, &$form_state){
//Add code to check the title using db_query
$title = $form_state['values']['title'];
//$fetch data from node table w.r.t this $title
//if title exists
form_set_error('title','custom message');
}
Here how can I compare new node title with already entered nodes in database?