Error message

Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /home1/tylerfra/public_html/includes/common.inc).

entity reference

Drupal User Entity Reference Field with Custom Autocomplete that uses an Address Field

User reference fields (aka entity reference fields) are great. As you may have guessed, we can use these fields to reference users on other entities (e.g. nodes).

Say we had a user reference field on the Article content type... by default, when selecting a user to reference, we could configure the field widget to be an autocomplete. This allows us to begin typing the user's login name as a way to reference them. This works well in most cases.

What if we had an address field on our user entities, and collected the user's first and last names? It may be more usable for site administrators to be able to search across the user's actual name instead of their user name for logging in.

We can use hook_menu(), hook_form_BASE_FORM_ID_alter(), and a custom callback function to provide a custom autocomplete widget that searches across our address field's values instead...

Subscribe to RSS - entity reference