Project:Unique field
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed (duplicate)

Issue Summary

This may be above and beyond the idea of this module, but it would be incredibly helpful if it was able to allow a unique field dependant on a taxonomy term.

For example, I've got a simple node type that has a taxonomy term selection and a date field.

To illustrate, a monthly checklist is created for each city (taxonomy term). 'Vancouver' needs its own 'Feb 2008' while 'Toronto' needs its own 'Feb 2008'. Currently, I can only use 'Feb 2008' once, no matter its term.

Comments

#1

One way to approach this would be to use Content Taxonomy (http://drupal.org/project/content_taxonomy ) which allows to expose existing taxonomies as fields. Then unique_field would be used to constrain the uniqueness of a combination of a title plus a taxonomy term. Too bad such a setup does not work though, giving me an error
warning: Invalid argument supplied for foreach() in /home/mysite/public_html/sites/all/modules/unique_field/unique_field.module on line 158.

#2

Hi bsuttis and sterwa,

The latest version of Unique Field is compatible with the Content Taxonomy module, so you can use Unique Field to require that terms used in Content Taxonomy fields are unique.

However, the Unique Field module does not currently support requiring that taxonomy terms used through the core taxonomy system are unique. If you are able to sponsor development of this feature, please contact me by e-mail.

#3

Status:active» postponed

#4

Because I needed this for a D5 site, here's a first stab at it. I'm sorry I don't have time to do a D6 version at the moment, but would like to revisit this when I do. Hopefully in the meantime somebody else can have a go.

(For D6, you won't need the $qjoinfield variable I added; this is just to get around the way D5 taxonomy terms are assigned to node IDs instead of revision IDs.)

Limitations I know of:

  • With vocabularies that allow multiple terms, you can only do an OR query on the terms in each vocabulary. That is, you get uniqueness on each term in a vocabulary, but you can't enforce uniqueness on particular combinations within a vocabulary.
  • The form_set_error() call doesn't send the correct field key, so the taxonomy field isn't highlighted. Should be fairly easy to fix.

Apart from that, seems to work for me. YMMV.

AttachmentSize
unique_field-5.x-1.0_taxonomy_support.patch 3.25 KB

#5

Status:postponed» needs review

#6

Version:5.x-1.x-dev» 6.x-1.x-dev
Status:needs review» closed (duplicate)

Appears to be fixed in #375409: Unique taxonomy term?.