Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I know, this problem is known for the 7.x-Version. But I have a similiar behavior in 8.x-Version. I have two fields, one option-list (taxonomy) and one simple text-field. Both are required fields and are controlled by a simple boolean-checkbox. Show and hide works perfect, but if I send the form, the hidden field is required.
I've tested this behavior with with grouped fields inside a fieldgroup and a simple setup (all fields in node-form withour fieldgroup).
Maybe I can solve this prblem with setup, but please give me a little "how to".
Thank you
Comment | File | Size | Author |
---|---|---|---|
#5 | Hidden element not required.PNG | 10.64 KB | C.E.A |
Comments
Comment #2
rgeerolfI have the exact same issue. Also tested with and without fieldgroups. I also tested with and without setting the option list (taxonomy) optional (!required) if the control boolean is unchecked.
Comment #3
koushikuk CreditAttribution: koushikuk commentedI am facing similar kind of problem. I have made a field required using conditional field. But when the event triggers(to make the field required) then the field shows required mark but required validation is not working.
Any help will be appreciated.
Comment #4
rbrownellComment #5
C.E.A CreditAttribution: C.E.A commentedUSE CASE:
Target Field: Text Box (Required)
Controlled By: Boolean
Condition: Text Box field is 'visible', when Boolean field 'is checked'.
Logically speaking, the Text Box field must be (Required) when visible and (Not Required) when hidden.
Which is not the case with the functionality of this module!
Note that the webform module has already find a solution for such use-case-condition:
Thank you,
Comment #6
C.E.A CreditAttribution: C.E.A commentedComment #7
Publishing Future CreditAttribution: Publishing Future commentedSame problem here. This is a killer for the use of this module. No progress for more than two years...
Comment #8
hannessthis should be fixed since #2983381: Make invisible imply unrequired and empty.
we use a text list field to show required taxonomy fields depending on the selected values. if they are not shown, we are able to save the form.
does this work for you? if it does, but does not in your scenario, it should be mentioned in the other issue.
if emptying the field is problematic, this would need a new issue and mention in the other issue.
Comment #9
cedeweyI am running into this problem as well.
In my case, I am using a boolean field on the user registration form to determine which profile fields, provided by the Profile module, to show. I've set the following conditional rules:
They are all using AND operators.
When I try to create an account, I cannot because the required fields for the profile type I am not filling out are still marked as required.
I'm using Conditional Fields 8.x-1.0-alpha7 with Drupal 8.8.5
Comment #10
Ginovski CreditAttribution: Ginovski at iqual AG commentedSame here, field is required when it is hidden due to a condition.
Comment #11
droprocker CreditAttribution: droprocker commented+1
I'm using this for conditional media entity references. The image field in the hidden media entity reference is still required.
Comment #12
prabha1997 CreditAttribution: prabha1997 at Valuebound for Valuebound commented+1
Same here, field is required when it is hidden.
Comment #13
JasonLuttrell+1
The issue still occurs in 8.x-1.0-alpha9.
Comment #14
Percept CreditAttribution: Percept commentedHas anyone tried to add 2 conditions ... 1 to remove "required" requirement and 1 to hide the field?
I just tested with just "invisble" for a required field based on a taxonomy term reference value in another field and had no problems (8.x-1.0-alpha9)
Comment #15
realgt CreditAttribution: realgt commented#14 works for me, except i made the field optional by default in field settings and then only made it required based on the control field value. i have an additional condition to make it visible based on control field value.
Comment #16
Rohit Tiwari CreditAttribution: Rohit Tiwari at Srijan | A Material+ Company for Drupal India Association commentedMy use case is:
1) I have a checkbox and on enabling it i show two plain text field
2) Either of these two fields are mandatory. (If one has value, other one becomes optional)
When i create new node, it does not let me save the node.
I am only able to save the node if i check and uncheck the checkbox field once (No data entered)
Comment #17
melnz CreditAttribution: melnz commentedI am having this same issue where one of two fields should be visible based on the value in another field.
The correct field is being hidden but is being set to 'required' when it shouldn't be, and it's hidden so the user doesn't know there's an outstanding required field.
How have others got around this?
Version 9.2.6
Comment #18
jsutta CreditAttribution: jsutta commentedI have this problem too. I'm on version 9.2.7.
In my situation, I have a checkbox and two text fields. If the checkbox is checked, Field 1 should be visible and required. If it's not checked, then Field 2 should be visible and required. Like others have said, the required mark and visibility work, but actually making the fields required so one or the other has to have a value doesn't seem to work.
Comment #19
anup.sinha CreditAttribution: anup.sinha at Infosys commentedI am also facing the similar problem in Drupal 9/10. I have used "#states" property to show or hide a field based on a selected value from another field. But even when the fields are hidden, it's showing validation message that the field value is required. As per my opinion this should be fixed in core.
Thanks & Regards,
Anup
Comment #20
SocialNicheGuru CreditAttribution: SocialNicheGuru commented