Hello,

I searched the forum for this issue, but didnt find anything.

I'm using CCK for my custom field needs and it works perfect.

I have a question, tho. How do i make one of this fields unique?

I'm using Drupal to create a record of my company's personnel, and to prevent duplicate entries in the record, i need one of the required fields (Telephone number) to have a unique value in the database.

Because, each worker has his own private telephone number. So, if the website user tries to create a new record, with a telephone number that is already there (assigned to a different record), he should get an error message.

Hope someone can help me with this.

Thanks in advance.

Comments

challer’s picture

would love to do a check if the value users submit in a specific field is already stored in the db. Maybe there's a solution using the computed fields module, but unfortunately I'm not good enought of a developer to tackle this.
Any hints would be very much appreciated.

drupalnesia’s picture

I am handle this problem by creating a unique index (directly alter the table using sql yog or phpmyadmin).

drupalnesia’s picture

Using a unique index as the backend solution but user will see the default mysql error message, including the table name.

If you need a better error message please read this post: http://drupal.org/node/89599

yasheshb’s picture

and there's a quick fix at http://groups.drupal.org/node/6195

hth.

yashesh bhatia

----------------------------------------------------------
Go Pre
http://www2.localaccess.com/rlalonde/pre.htm
----------------------------------------------------------

Yashesh Bhatia

AndreasST’s picture

Hello yasheshb!
Found your function, and it seems to be what i need.
Only have one question:
How to implement, call, ... or what ever the function to get it work?
Sorry, i nearly "understand" your code, but do not know enough about drupal´s core and php to do this on my own.

arithmetric’s picture

I've released a module called unique_field, which provides an interface for requiring that node titles or CCK fields have unique values. It is available from:

http://drupal.org/project/unique_field

I'd appreciate any comments or suggestions.

doomed’s picture

detour, it's great that you did this!

i'll try it soon.

Daiki Lebeau’s picture

Good Morning !
well, I installed and activated unique field in my drupal 7 and I thought that the parameters of this module will be displayed when you want to create a field but it is not so please jv would like to know how it is used!
Thank you for answering me!

mr_dimsum’s picture

I'm new to Drupal. Wait, so what you're basically saying is that the fields in CCK do not create separate values for each field? Based on what you've written, this is the idea I'm getting in.. If so, this poses a huge problem towards any type of filtration of the input.