1

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

1 Answer 1

1

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.

4
  • I've tried this. The problem is that all the dependents are visible when I do this.
    – user22939
    Nov 24, 2013 at 5:38
  • I've already tried many conditions so far, but still haven't been able to get this module to do what I want. Would you happen to know of another module that is capable of hiding fields when certain conditions are met? Or maybe an alternative method for achieving what I'm trying to do?
    – user22939
    Nov 24, 2013 at 6:15
  • 1
    I remember now-- Conditional Fields required function does not work right now. I would link you to the issue but the drupal.org issue search isn't behaving. See my updated answer. Nov 24, 2013 at 6:25
  • Thank you very much sir. This module is exactly what I was looking for!
    – user22939
    Nov 24, 2013 at 8:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.