When activating a dependency that changes the required state of a field, a red asterisk is added to the field on the front end but no required validation is added and the entity can be saved without values in those fields.
Both modules, Conditional Fields and Field Conditional States, are based on the states.api and don't fix the problem either - a very old and annoying issue not solved within 3 years:
#1561272: Conditionally required fields are not required
#2306401: Enforce the state "required"
#2396685: Conditionally required fields are not required
Is it really that difficult for a skilled programmer (which I'm not) to fix this problem using drupal validation in combination with jquery (hide, fadeIn, addClass, removeClass)?
There are things that should be considered as pretty basic (from scratch) when using "powerful" CMS like Drupal - this is definitely one thing!
Comments
Comment #1
rooby CreditAttribution: rooby commentedComment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedThe issues you refer to are part of contrib, not core. And AFAIK conditional fields are not part of D8 core either. So I'm not really sure why you filed this issue here. Can you elaborate on what the D8 core bug is exactly?
No, not really. But writing a specific solution in a custom module is definitely not the same as writing code for a drupal contrib module, let alone a core module.
...
Comment #3
rooby CreditAttribution: rooby commentedI thikn what they are referring to is the required state in the states api.
The problem is that it allows setting a field to be required but it isn't actually required, it just has a red asterisk.
Comment #4
rooby CreditAttribution: rooby commentedComment #5
fengtanWe can reproduce this in Drupal 7.50 -- not sure about Drupal 8.
Say you have this form:
When checking my_checkbox, a red star shows up near my_textfield and suggests it is a required field. However, we can submit the form even if my_textfield is empty.
Comment #6
antiorario CreditAttribution: antiorario commentedThis was in the wrong spot, but it's also a duplicate of #1561272: Conditionally required fields are not required.