You are here

public function FieldDefaultTokenEmptyAlter::is_empty_alter in Field default token 7

Alter the empty status of a field item.

Overrides EntityReference_BehaviorHandler_Abstract::is_empty_alter

File

plugins/behavior/FieldDefaultTokenEmptyAlter.class.php, line 16
Additional behavior for Entity reference fields.

Class

FieldDefaultTokenEmptyAlter
Prevents field value containing tokens from being treated as empty.

Code

public function is_empty_alter(&$empty, $item, $field) {

  // If field value contains tokens, entityreference.module treats it as empty.
  if ($empty && isset($item['target_id']) && strpos($item['target_id'], '[') !== FALSE) {
    $empty = FALSE;
  }
}