Skip to content
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

Category field: Able to select multiple when limited to only one selection #1847

Open
Luuc15 opened this issue Jul 18, 2017 · 6 comments
Open
Labels
bug severity:minor Cosmetic issues or bugs with simple workarounds

Comments

@Luuc15
Copy link

Luuc15 commented Jul 18, 2017

Description

When you have a category field and a limit to select only one category for an entry, then it is still possible to select multiple categories (using shift + click or cmd + click or ctrl+click), although only one will actually be used when clicking the button to use the selected categories

Steps to reproduce

  1. Add a category field to an entry that is limited for 1 category selection
  2. Select multiple categories by using shift + click or cmd + click (on windows ctrl + click)
  3. Now click the bottom right button in the popup to use the selected categories
  4. Only one of the selected categories will be used in the entry.

Additional info

  • Craft version: 3.0.0-beta.21 - 2017-07-07
  • PHP version: 7.0.15
  • Database driver & version: Mysql version 5.6.35
  • Plugins & versions: No plugins

Step 2 - Selected two categories:
schermafbeelding 2017-07-13 om 13 59 19

Step 4 - Only the category "PLAY" is used:
schermafbeelding 2017-07-13 om 13 57 32

@brandonkelly
Copy link
Member

The issue is that the modal doesn't know about the field's limits. A similar issue also exists for Assets, Entries, and Users fields, when a limit is set on them - the limit won’t be applied until after a selection has been made.

It’s especially complicated for Categories though, since it’s a “Branch Limit” rather than a hard limit on how many individual categories can be selected.

@Luuc15
Copy link
Author

Luuc15 commented Jul 20, 2017

I tested this with the Entries field (content field) and there the problem does not exist.
When repeating above steps for the entries field, the problem does not occur and the behavior is as expected

@brandonkelly
Copy link
Member

If you have an Entries field with a limit of 5, you will be able to select > 5 in the modal, but only 5 will be selected after you click Select.

@hiasl
Copy link
Contributor

hiasl commented Aug 10, 2017

My opinion, since this topic comes up again and again: I understand the idea of a branch limit, but honestly I do not understand, why selecting a third level category actually selects the 2 parents too. Ignoring parents is more difficult than explicitly querying them would be (especially if a category has/d a method for this purpose), in case you need them. With such a logic the branch limit would be the same as a category limit and I guess limiting it could be easier. Just an idea, though a total change of behavior.

@brandonkelly
Copy link
Member

@hiasl This is pretty typical behavior for taxonomies, where sub items inherit from their parents.

Given the following taxonomy:

  • Food
    • Fruit
      • Apple

Anything that is categorized as an Apple should always also be categories as a fruit, and also food.

If that general logic does not apply to your taxonomy, then you are probably not organizing it correctly.

@hiasl
Copy link
Contributor

hiasl commented Aug 15, 2017

You are totally right with your taxonomy, which should exactly be as in your sample. But let's take this one step further. Think about recipes (and please ignore quantities at the moment) and let's organize ingredients via categories. Let's add a second fruit "banana" on the 3rd level.

When I organize that in craft and select 2 ingredients (apple, banana), it's totally logical and correct that these are also fruits and food, but it's not important to the use case. The recipe's editor would select the ingredients and when I iterate over the selected ingredients I need to drop out the parent elements manually although neither the editor meant them to appear nor is it important to me, what the parent elements are (I assume this will be the case on most applications).

In my case I organize events with "country > city > venue" via categories. Same thing here. Country is an important information, when I filter my events, but the main information is the last (childless) level.

What I'm just saying is that I assume that more often you will only need the last level. Or to be more general: There's a need for both. But actually this discussion is drifting off the issues' topic :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug severity:minor Cosmetic issues or bugs with simple workarounds
Projects
None yet
Development

No branches or pull requests

3 participants