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

CommentFileSizeAuthor
#5 Hidden element not required.PNG10.64 KBC.E.A
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kay.beissert created an issue. See original summary.

rgeerolf’s picture

I 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.

koushikuk’s picture

I 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.

rbrownell’s picture

Category: Support request » Bug report
C.E.A’s picture

USE 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:

Hidden element not required

Thank you,

C.E.A’s picture

Priority: Normal » Major
Publishing Future’s picture

Same problem here. This is a killer for the use of this module. No progress for more than two years...

hanness’s picture

this 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.

cedewey’s picture

I 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:

  1. If profile type is set to "Individual" mark Individual Profile as visible
  2. If profile type is set to "Individual" mark Organization Profile as invisible
  3. If profile type is set to "Organization" mark Organization Profile as visible
  4. If profile type is set to "Organization" mark Individual Profile as invisible

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

Ginovski’s picture

Same here, field is required when it is hidden due to a condition.

droprocker’s picture

+1

I'm using this for conditional media entity references. The image field in the hidden media entity reference is still required.

prabha1997’s picture

+1

Same here, field is required when it is hidden.

JasonLuttrell’s picture

+1

The issue still occurs in 8.x-1.0-alpha9.

Percept’s picture

Has 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)

realgt’s picture

#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.

Rohit Tiwari’s picture

My 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)

melnz’s picture

I 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

jsutta’s picture

I 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.

anup.sinha’s picture

I 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

SocialNicheGuru’s picture