I wonder to know is it possible to have an unique field (let consider a text filed), when we input a data into it firstly it check the table if it doesn't exist add a record, if it find a record refer to it?

i.e.: I have a field in my content type to store telephone number whenever I want to add a new node, after entering the data into the telephone field if the number was stored in my database instead of creating a new record in the table I just reference to the number

My aim is to have a contact list of some users that submit a form but I don't want duplication (just unique phone number and name)

  • did you used hierarchical select module??
    – Adi
    Dec 18 '15 at 12:12
  • Thanks Adi for your reply. I used it before but how the module can deal with my problem?? Dec 18 '15 at 12:17
  • install this module and define term field in your content type when everytime you create a record already enter record display in select list
    – Adi
    Dec 18 '15 at 12:24
  • but it just show those phone numbers that I've created before, I'm not able to add a new record automatically. Dec 18 '15 at 12:36
  • simple disable option to add new value
    – Adi
    Dec 18 '15 at 13:25

I would envision this as

  • Create a rule that post a node each time the form from anonymous user is submitted.

  • Create a condition before creating a node - the condition will loop through all entered node telephone numbers if they found that the user has already entered the data don't do anything other wise post the node with phone, name and email information.

  • Thanks Shabir but I don't want to be stopped. I need to reference to the record Dec 18 '15 at 12:59
  • You can add a validater function in node form alter and once the validation of uniqueness failed load the node by phone number and populate the values, I am not sure what you mean by reference. Do you want to update the values in that case?
    – Shabir A.
    Dec 18 '15 at 13:01
  • no I just want to use the number same as select list. Dec 18 '15 at 13:05
  • Okay, what happens if the number already exists? I am sorry but I am not getting your words
    – Shabir A.
    Dec 18 '15 at 13:10
  • may be you could look at this drupal.org/project/field_reference module
    – Shabir A.
    Dec 18 '15 at 13:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.