You are here

function unique_field_node_settings_form_validate in Unique field 6

Same name and namespace in other branches
  1. 5 unique_field.module \unique_field_node_settings_form_validate()
  2. 7 unique_field.module \unique_field_node_settings_form_validate()

Form validation callback for unique_field_node_settings_form.

1 string reference to 'unique_field_node_settings_form_validate'
unique_field_node_settings_form in ./unique_field.module
Add the unique field settings form to content type forms (node_type_form).

File

./unique_field.module, line 471
Provides content validation requirement that a node's title, author, language, taxonomy terms, or CCK fields are unique.

Code

function unique_field_node_settings_form_validate($form, &$form_state) {
  if ($form_state['values']['unique_field_scope'] === UNIQUE_FIELD_SCOPE_NODE) {
    if ($form_state['values']['unique_field_comp'] === UNIQUE_FIELD_COMP_ALL) {
      form_set_error('unique_field_comp', t('The scope of a single node requires that each field must be unique.'));
    }
    foreach ($form_state['values']['unique_field_fields'] as $fname => $fval) {
      if ($fval && ($fname === UNIQUE_FIELD_FIELDS_AUTHOR || $fname === UNIQUE_FIELD_FIELDS_LANGUAGE || strpos($fname, UNIQUE_FIELD_FIELDS_TAXONOMY) === 0)) {
        form_set_error('unique_field_fields', t('The author, language, and taxonomy fields are not supported within the scope of a single node.'));
        break;
      }
    }
  }
}