I am a Drupal 7 novice. I have two fields of two different contents in a view. The first field is a boolean and the second is text (configured to an external link). Now, I want to make a condition like "If the first field is Yes, then the second field should be hidden."

  • There is also drupal.org/project/field-conditional-state – junedkazi Jan 29 '13 at 16:26
  • Yes I need it only for a view. I think I have not explained my problem clearly. Here it is. Field 1 is Delivery (yes/no); Field 2 is Deliver (Global Text with link to open a form); both fileds are displaying in a row of a table view. Requirement: If Delivery / yes then Deliver / yes (without link); If Delivery / no then Deliver / yes (with the link which will open the form to edit); I hope it is clear now. – bane Jan 30 '13 at 6:19
  • So, isn't my answer useful ? – Gregory Kapustin Feb 1 '13 at 13:35

This can be accomplished through the Form API. However, if you are a PHP novice, you would probably be better off using the Conditional Fields module. Although this is still in dev (no official release) for Drupal 7, it does work. (If you have security-related requirements, you should use Form API instead though.)

Basically, the module provides you with a UI for adding conditions to fields. The example you give is the same given on the module's page, so this is one solution to your problem.

| improve this answer | |
  • Thanks for your help. I can try Form API for a Form but how to use it in a view as per my requirement ? views_ifempty module might be helpful and trying to solve the problem with this also. Your suggestion please. – user13171 Jan 29 '13 at 12:39

I guess your question is about views, whether displaying a field or not, not in the node form.

Then my advice, without using views PhP, would be to use no-result behaviour in your view :

  1. Add your text field, and hide it
  2. Add your boolean field, and use rewrite the output, and in it set your text field with the given token
  3. Use no result behaviour on that field, and put either nothing, either what you want to be displayed when your boolean field is set to no.

Hint : for your no result behaviour to be triggered when your boolean field is set to no, you have to ensure the key of the "no" is either "0" or empty. To be sure, check the option Count the number 0 as empty .

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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