How to get a conditional dependency to work? I have 2 fields in my content type 'test':


'Photos Gallery' -field type is image
'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).
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:


Check for "entity has field" (for field = Enable)
Check for "entity has field" (for field = Photos Gallery)
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.
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.