Search code examples
drupal-7fieldrequired

How to make in drupal 7 a field required only after another field is filled out?


In drupal 7 i have a view slideshow. Every Content admin can add an article in the site and the slider gets some of them filtered with specific filters based on some categories related to the articles.

As the Content admin edits the article has a drop down list option (Yes/No), to either show the article in the slider or not.(this is the first filed)

If he selects Yes, another field needs to be filled too. It's an image field which will be displayed at the end in the slider.

Just selecting Yes (at the dropdown list) and no image (at the image field) causes troubles to the slider. Empty place at the pager and less shown objects (cause it counts all the filtered items but showing only the ones that have an image)

I need to make the second field (image field) required ONLY IF the first field is selected to Yes option.

How can i do that?

P.S. please excuse my English...hope you understand what i am trying to explain.


Solution

  • You have to use conditional_fields module
    Refference : [https://drupal.org/project/conditional_fields][1]
    This module offers one field is depedent on another field's value.
    

    Enter which image id dependent field and dropdown is dependee and The dependent(image) field is choose required from dropdown when dependee(dropdown) field has value choose Yes see screenshot enter image description hereAlso see setting option after install module.

    enter image description here