Examples

Last updated on
24 December 2018

Drupal 7 will no longer be supported after January 5, 2025. Learn more and find resources for Drupal 7 sites

Example 1: Countries and cities

Suppose your node on which you want the limiting widgets to be is Restaurant, and you have Countries and Cities nodes too.

Your 'limiting field' is the Countries reference on Restaurants: this limits the value of another field.

Your 'option-limited' field is the Cities reference on Restaurants: this is the field whose values you want to be limited.

You need the following fields:

  • A reference field on Cities, which points to Countries: this lets each City entity know which Country it belongs to
  • A reference field on Restaurants, which points to Countries. This field must have the same name as the other field which points to Countries
  • A reference field on Restaurants, which points to Cities. This field needs to be configured to limit itself according to the other field on Restaurants.

Example 2: Sports and teams

Suppose you want news stories to be marked as being about a sport and a particular team for that sport, perhaps using taxonomy terms for both. To make editing easier, you would probably like want the 'team' dropdown to be limited to just teams for the current news story's sport.

To achieve this with this module, add the 'sport' field to both news story nodes and team taxonomy terms. Hence the team 'Chudley Cannons' would have as its sport taxonomy term 'Quidditch'. (This probably entails taxonomy term reference fields on terms themselves... which was bound to happen with FieldAPI sooner or later.)

Thus, when editing a news story node, selecting 'Quidditch' as the sport will cause the team reference field widget to update to show only teams which also have 'Quidditch' as their sport.

Example 3

Suppose:

  • the option limited field (i.e. the field you want to limit) is on entity type A.
  • this field points to (i.e., refers to) entities of type B.

Then

  1. Add your entity reference field on entity type A as normal. This will be the option limited field.
  2. Add a field to entity type A whose values will be used to limit the option limited field.
  3. Add the same field to entity type B, ie use the 'add existing field' portion of the field UI
  4. Return to the option limited field settings and select field B as your matching field.

Example 4

  1. Add your entity reference field, which you want it to be limited by taxonomy terms, to an entity. (ex. node type)
  2. Add your taxonomy term field from the existing fields to the same entity. Note that the entity reference you added has to have the same taxonomy terms fields in it.
  3. Go and edit the first entity reference field you have included, there appears the option limited field. Edit the settings as you like.

Help improve this page

Page status: No known problems

You can: