Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't allow choices with same value in dropdown #13371

Closed
Pitcentr opened this issue May 18, 2022 · 5 comments
Closed

Don't allow choices with same value in dropdown #13371

Pitcentr opened this issue May 18, 2022 · 5 comments

Comments

@Pitcentr
Copy link

Describe the Bug

When you create a multiple list with the same values, an error occurs, selecting one selects all the others

To Reproduce

https://recordit.co/eLAkM8n9Hm

изображение

изображение
изображение
изображение

Errors Shown

No response

What version of Directus are you using?

9.10.0

What version of Node.js are you using?

v14.19.1

What database are you using?

mariadb

What browser are you using?

Firefox

How are you deploying Directus?

npm

@azrikahar
Copy link
Contributor

Is there a particular reason to have multiple choices with the same value? If it's intentional, I personally wouldn't categorize this is a bug or error, but I do agree it can be improved in the sense that duplicate value should be prevented (or maybe overrides the previous value).

@azrikahar azrikahar changed the title Error when selecting a checkbox Don't allow choices with same value in dropdown May 18, 2022
@Pitcentr
Copy link
Author

you need for the opening times by day of the week,
0 - Monday 8:00-19:00
1 - Tuesday 8:00-19:00
....
5 - Saturday 9:00-16:00

@azrikahar
Copy link
Contributor

I believe an M2O field would be more suitable and flexible in such scenario, but understandably it can be difficult to understand the data modeling decisions made here without full context. I'll defer to @rijkvanzanten on whether this is a change we'd like to make (and/or any potential unforeseen pitfalls).

@sxsws
Copy link

sxsws commented May 24, 2022

First, OP is wrong. You have the text value in the value input and vice versa. It should be the other way around. Then technically, the values aren't duplicates as the values for each choice are different.

I believe an M2O field would be more suitable and flexible in such scenario,

This. Personally I too tend to always use an m2o solution with a table being able to offer user editable choices and easy changes for the future. An isActive field can be used to filter them if I want to disable them at any stage. It would be a nightmare to have to remember where I've defined certain choices like this that 6+months down the line need to be changed. For clarity, I suffix all such collections with Types, so paymentStatusTypes, organisationTypes etc.

Also, in the case of business hours, I just use a repeater which an open time / close time structure.

@Pitcentr
Copy link
Author

Thanks for the answer, in my example I create a field user mode (company) this field for each company is unique and different will create many duplicate M2O records, I created a field JSON and just in this case will store it in this form

@directus directus locked and limited conversation to collaborators May 24, 2022
@rijkvanzanten rijkvanzanten converted this issue into discussion #13509 May 24, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

3 participants