I have 2 fields in my content type 'test':

  1. 'Photos Gallery' -field type is image
  2. 'Enable' checkbox to Enable gallery (field type boolean)

Required output: When 'Enable'-field is checked, the node should not allow us to save with empty photos in the 'Photos Gallery' field and we should be able to save if 'Enable' is unchecked.

I tried the Conditional Fields module and given condition like 'Gallery Photos is required when Enable is checked.', where 'Gallery photos' is dependent and 'Enable' is dependee field.

Current output: In the node edit page , when 'Enable' is checked, asterisk (*) can be seen near 'Gallery Photos' , but without adding photos if i save, it is allowing me to save, without any error.

What additional settings I need to do, apart from dependency settings?

Note: I'm also interested in possible alternative solutions to get this to work (instead of using Conditional Fields).

  • Are you interested in alternative solution (instead of conditional fields)? Feb 10, 2016 at 11:16
  • 1
    sure..Is there any alternative solution
    – rks
    Feb 10, 2016 at 11:19

1 Answer 1


As an alternative solution to using the conditional fields module (cfr your comment in your question), you can use the Rules module for this. Here are some details (the pseudo code) about how to do so:

  • Rules Event: Before saving content.
  • Rules Conditions:

    1. Check for "entity has field" (for field = Enable)
    2. Check for "entity has field" (for field = Photos Gallery)
    3. Compare the value of the "Enable" field, for both the original value (before editing the field) and the (new) updated value, to verify if they enabled (checked) this field.
    4. Check if field "Photos Gallery" is empty.
  • Rules Action: display an error message to explain that your validation failed. For an example of how to display an error message using rules, refer to my answer to "How to make the permissions of a module more granular?" (which actually includes 2 actions, you only want the drupal_message part of it (probably not the redirect to somewhere else).

To understand the need for those Rules Conditions "1." and "2.", have a look at my answer to "How to check in a rules condition if an image field has value?"

Should be straight forward to "develop" such rule, no (PHP) coding at all involved (only site building using admin UI).

Video tutorials

If you're not familiar (enough/yet) with Rules, checkout the 32 (!!!) great, and free, video tutorials Learn the Rules framework, organized in 7 chapters.

  • 1
    Thank you for the detailed explanation,or else it was confusing.
    – rks
    Feb 11, 2016 at 10:16

Your Answer

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

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