0

I am using Drupal 7 with the Entityform and Conditional Fields modules to build a form and need to see if it is possible to disable a value in one field based on the selected value of another field. Here are the details:

Field: Source Region List (Text) - Radio Buttons

Values: US-East US-West APJ EMEA

Field: Destination Region List (Text) - Radio Buttons

Values: US-East US-West APJ EMEA

The behavior I am looking for is this: When a region value in Source Region is selected, I need the corresponding value in Destination Region to be disabled but the rest of the values to be selectable. This is to make sure the Source and Destination regions are not set to the same value.

Example: Source Region selected value is US-East, I need Destination Region US-East gets disabled.

If this is not possible with the Entityform and Conditional Fields modules, please let me know how best to obtain this functionality. If this means writing a form from scratch, I am willing to do this but need some type of tutorial or howto document to learn how to do this.

1

I doubt whether it is possible. You cannot hide certain radio options in a radio group. It is the whole group or nothing. I will look rather at a custom jQuery solution coupled with a server-side validation method.

The jQuery will have to: display all hidden radio options in destination, then hide the corresponding radio option in the destination when source is selected. You will have to add the jQuery to the page via hook_preprocess_html or something similar, or use the module JavaScript Libraries Manager.

Server-Side: You can use the Field validation module. Put the validation against both fields, and use 'Equal values on multiple fields', and set it to reverse.

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.