You are here

function _entityreference_autofill_field_has_value in Entity reference autofill 7

Check if a field has an input value.

Parameters

array $items: Array of items in the fields $form_state['input'] array.

string $field_name: The name of the field in question.

Return value

bool Whether or not a value is set for this field.

1 call to _entityreference_autofill_field_has_value()
entityreference_autofill_populate_form_by_field in ./entityreference_autofill.module
Populate other form fields with respect to this module's field settings.

File

./entityreference_autofill.module, line 440
Entity reference autofill module.

Code

function _entityreference_autofill_field_has_value($items, $field_name) {

  // Find out if field implement hook_field_is_empty.
  $field_info = field_info_field($field_name);
  $function = $field_info['module'] . '_field_is_empty';

  // Check if empty.
  if (function_exists($function)) {
    foreach ($items as $item) {
      if (!$function($item, $field_info)) {
        return TRUE;
      }
    }
    return FALSE;
  }

  // Fallback to recursive array check.
  return _entityreference_autofill_field_array_value_exists($items);
}