verbb / single-cat

Field type for CraftCMS that allows the user to select a single category from a drop-down.
MIT License
11 stars 5 forks source link

Allowing blank option silently fails validation #10

Closed jlawrence-yellostudio closed 4 years ago

jlawrence-yellostudio commented 5 years ago

Hi @elivz

I'm using this in a matrix within a supertable and if I set the single category field to required and then choose the blank option it silently fails. I get an indication that the error is on that page and the matrix block has vanished.

Arguably now thinking about it further maybe the blank option is redundant given that that is what the required flag on the field does? Can you elaborate on the purpose of it?

elivz commented 5 years ago

Hmm, interesting. I will check that out as soon as I get a chance (probably this weekend). The reason for having the blank option is to force people to make a choice (rather than just defaulting to whatever item is first). But it shouldn't remove the Matrix row if it fails validation. I will figure out what's going on.

elivz commented 5 years ago

I'm afraid I haven't been able to replicate what you are describing. I might have misunderstood the situation, but I created a SuperTable field with a Matrix inside it with a Single Category field inside that. I set all three levels to "required". When I leave the category field blank, I get a red error message, as I would expect. See screenshot below. Am I doing something differently from what you have?

Screen Shot 2019-06-01 at 3 31 08 PM