Conditional fields module - Required fields that are hidden are still required to be filled I'm using the Conditional Fields module to create dependencies that hide/show certain fields in a shipping/billing information form.

In the form, I have 1 "List (text), select list" field which is used to select the dependees for 3 dependents. The dependents are 2 "List (text), select list" fields and 1 "Text" field. All fields are set to be required in their field settings.

I have each dependent set to be invisible unless its' dependency is triggered. My problem is that after triggering one dependency, the 2 remaining dependents, which are hidden, are still required even though they are hidden. When submitting a form, this causes an error message to display saying:

"x field is required

y field is required"

::My settings for each dependent are as follows::

Condition: Value

Values input mode: None of these values (NOT)

Set of values: "My selected value(s) that trigger(s) the dependency"

Interaction with other dependencies: XOR

Form state: Invisible

Effect: Show/Hide

✓ Hide the dependent if the dependee is not in the form

✓ Hide the dependent if the dependency is not triggered

✓ Hide the dependent if the dependee is not viewable by the user
All fields are set to be required in their field settings.


This is your mistake.  If you set the field to be required in the field settings, it will be required whether it is invisible or not.  So you need to uncheck this setting unless the relevant field will always have a value.

Instead, you should trigger the "make required" action provided by the Conditional Fields module whenever showing the relevant field for input.  Unfortunately, the last time I tried this in Conditional Fields, it did not work due to a bug.

Alternatives

Field Conditional State is a stable module that works similarly to Conditional Fields.  You can use this to properly set required fields.

Or, if you prefer a code-based solution, look into the #states API.