ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Forcing Entry Title to be unique

October 14, 2010 1:43pm

Subscribe [4]
  • #1 / Oct 14, 2010 1:43pm

    bbormandev

    2 posts

    I have a client that is using ExpressionEngine to display some items. Each item has a number and they are storing this number as the entry’s Title for convenience. However, they discovered that they are able to enter an item twice since the entry Titles allow duplicates, yet the item numbers are expected to be unique.

    I can understand why it would allow duplicates, as well as I can understand why it would be desirable to make them unique at times.

    I was wondering what the best approach would be to solving this issue other than the obvious manual pre-search?

    Is there any way to make a custom field be unique?

    This client is using EE 1.6.8 though I would be interested in any solutions for EE 2 as well?

    Thanks!
    Brian

  • #2 / Oct 14, 2010 3:17pm

    Ingmar

    29245 posts

    I am afraid there is no built-in way to enforce uniqueness for title fields. This would either have to be some custom code or a Feature Request.

  • #3 / Oct 18, 2010 11:45am

    bbormandev

    2 posts

    Great, thank you very much. Are there any common practices or models to use to work around this? I assume there had to be a scenario in which a field must be unique that others may have worked around before?

  • #4 / Oct 18, 2010 3:21pm

    Ingmar

    29245 posts

    Sorry, I’m really not aware of any ready-made solution. Let me move this to the CodeShare Corner for some more brainstorming.

  • #5 / Feb 09, 2011 6:50am

    johnny.slack

    4 posts

    Hi Ingmar,

    so, few months later (and a v2.1.3), is there still not any solution to make a title field or its value unique? We not only cannot use the url title, or the entry id in our work flow, but also find it very confusing that client might end up with a lot of entries with the same name.

    Were thinking, that at least there should be an error message or warning, if entry title already exist.

    Any ideas?

    Thanks!

  • #6 / Feb 10, 2011 8:23pm

    Mark Bowen

    12637 posts

    Just brainstorming on this one as it’s a fairly odd thing you’re asking for as I’m just wondering why if you don’t want duplicate entries how are they getting into the system in the first place?

    Are lots of people entering the same data at the same time then? Might be an idea to take a look at the data entry side of things if that’s the case.

    That said perhaps you could have a form (would need to use javascript) which has a function on the title field which once the user has typed the title they can either press a button to check its uniqueness upon which this would search the ExpressionEngine database and see if there is already an entry with that title and if there is won’t allow the form to be submitted. If there isn’t one with the same title then the user can carry on and submit the form.

    I can possibly see some problem with this though if you do have lots of people entering the data as there is still the possibility that two people (or more) might both be entering at the same time and they may have both already entered and checked the title upon which they would then be allowed to submit the form. This would then end up with duplicate titles.

    To this end the only way around all of this would probably be an extension to check the title on entering the data into the database. This is going to be a bit more work to do and you are going to have to have an error capture side to it so that if the entry does already exist you can take the user back to the form, tell them the problem but also keep all the data that they have already entered or they might get a bit annoyed.

    I still think that if the problem is that you have more than one person entering data into the system then really the input method needs to be looked at really.

    Best wishes,

    Mark

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases