You are here

function machine_name_value_exists in Machine name 7

Same name and namespace in other branches
  1. 7.2 machine_name.module \machine_name_value_exists()

Checks whether the machine name value is unique for the field.

See also

form_validate_machine_name()

1 string reference to 'machine_name_value_exists'
machine_name_field_widget_form in ./machine_name.module
Implements hook_field_widget_form().

File

./machine_name.module, line 109
Defines a machine name field type, relying on Form API's #type 'machine_name'.

Code

function machine_name_value_exists($value, $element, &$form_state) {
  $field_state = field_form_get_state($element['#field_parents'], $element['#field_name'], $element['#language'], $form_state);
  $query = new EntityFieldQuery();
  $query
    ->fieldCondition($field_state['field'], 'value', $value);
  $query
    ->count();
  return $query
    ->execute();
}