To Be, or Not To Be: the Empty Entity Reference

To be, or not to be, that is the question. Shakespeare never quite gets around to answering it, though. In Drupal 7, a similar existential question arises regarding entity references: Is it, or is it empty? Unlike Will, we can answer this question.

With other field types, we can check to see if the field is empty by doing something like this:

if (sizeof($form_state['values']['field_x'][LANGUAGE_NONE]) > 0)

Subscribe to entityreference