I'm setting up a contact form and would like to implement the following functionality:

  • On my form I currently have an entity reference field that references the content type 'Home Team' using a select list.
  • I would like to add another field to my form that populates with a select list of field data based on the content that is selected in the above entity reference field.

To help explain, each 'Home Team' has a field called 'home games' that is a list of text in the format 'Team Name - Date'.

I'd like it to be so that when a user chooses a team from the first select list, the second select list is then populated with that team's home games.

I think that the answer might be by using the Field Reference module, however I'm not sure how to implement what I am needing to do.

  • This is something the "Drupal AJAX API" can easily handle. You just need to write a form alter (if you're using a module such as webform) or implement the AJAX in your form if you're making your own form using Form API. Also have a look at the Ajax Example Module which has a "dependent dropdown" example. Pretty basic but it will get you going.
    – Beebee
    Commented Aug 14, 2015 at 1:28

1 Answer 1


You can use DFV - Dependent Field Values. It's a great module and does exactly what you're asking

The module's page says:

This modules enables site admins and developers to make the allowed values of a field depend on another proviously selected field's value.

You can use views with arguments to let views return the allowed values for a dependent field.

I'm using it myself, it's quite simple to use: you create a view of type Dependent Field Value with a contextual filter, which in your case is the NID of the node in the first field, the team (remember to add the relevant relationship in the view's Relationships section).

Usually you'll want to add two fields to this view, e.g. the home game's NID and the home game's title. After adding the two fields, click on the settings of the dfv list format. Choose the home game's NID as the Key Field an the home game's title as the Title Field. The view is done!

You didn't explain how is your contact form made, but I suppose that you use webform. So: you just have to go to the second field's settings, check the "Enable dfv settings", choose the parent field (team) and the view you just created.

  • 1
    Perfect! This is exactly what I was looking for. Works great, thank you very much for the help. Commented Aug 14, 2015 at 15:18

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.