Jump to content

Duplicate entry in select option


blanco
 Share

Recommended Posts

I have a select option were I try to add a new value with a specific id and title and getting this error message: 

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'Håbo kommun-114' for key 'title'

The thing is that there are no other item in the list with that id nor title. It's a list of all the counties in sweden which has specific id numbers. There are 290 of them, and all of them gets imported except one, and that is Håbo kommun with the id number 0305. 

I can't even see anything in the database table fieldtype_options. there is no item with that id. What could be causing this? 

Thanks!

 

 

Link to comment
Share on other sites

I played around with a fresh install of ProcessWire and tried to replicate your issue.

There are a few things I found:

  1. the select/option ID needs to be unique (obviously)
  2. the select/option value can be the same between different options
  3. the select/option title needs to be unique as well

While this works:

1=0305|Håbo kommun 114 A
2=0305|Håbo kommun 114 B
3=0305|Håbo kommun 114 C

This doesn't:

1=0305|Håbo kommun 114
2=0306|Håbo kommun 114
3=0307|Håbo kommun 114

See the differences there?

So... the easiest explanation would be that there at least one other entry with the same title.

My testing setup looks like this:

2021-04-22_19-40.png.e1db6ea809c218cb254cc2f553083870.png

 

If you like drop me a PM and send me the list of all counties you have and I'll test it here.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...