At the moment when a user gets an error message, it says "The "name of" field requires a unique value, and the specified value is already used."

Could you add add a link to the actual node so the text could read:

The {field} requires a unique value, and the specified value is already used {here} <-link to node

Or even a better way could be just to forward them to the actual node itself. This prevents users from ever seeing an error message.

Thanks

Comments

Fayna’s picture

I think the best way to handle this is to redirect the user to the already existing node.

crea’s picture

Status: Active » Needs work

If anyone wants to commit the patch, here is sample code I made for this feature
Find the line

$errmsg = 'The @label field requires a unique value, and the specified value is already used.';

and replace with the following:

$matches[$field] = '<ul class="unique-' . $field . '-matches">';
foreach ($match as $key=>$value) {
     $attribs['class'] = '';               
     $urltitle = url('node/'.$value);
     $matches[$field] .= '<li class="unique-' . $field . '-match">' . l($urltitle, 'node/'.$value, $attribs) . '</li>';
}            
$matches[$field] .= '</ul>';
$errmsg = 'The @label field requires a unique value, and the specified value is already used. Found matches: !matches';

Then find the line
form_set_error($field, t($errmsg, array('@label' => $labels[$field], '@labels' => join(', ', $labels))));
and change to
form_set_error($field, t($errmsg, array('@label' => $labels[$field], '@labels' => join(', ', $labels), '!matches' => $matches[$field] )));
This code will output found matches for single 'Each of the specified fields must have a unique value.' mode, but this can be easily adapted to work in all modes.
Full solution would be to expand this into unique-field setting like option "Show matching nodes", and show node titles as anchors, but this simple code was enough for my need

summit’s picture

Subscribing, please file a patch for this finding!
I also get this error when somebody wants to change older content, how is this possible please?

Thanks a lot in advance!
Greetings, Martijn

arithmetric’s picture

Status: Needs work » Fixed

Hi all,

I've added this feature to the module as of the beta 1 version. In the unique field configuration settings on a content type form, you will find a checkbox to enable showing which nodes were found with matching values. Only nodes that the user is authorized to view will be displayed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.