You are here

function unique_field_node_settings_form_validate in Unique field 7

Same name and namespace in other branches
  1. 5 unique_field.module \unique_field_node_settings_form_validate()
  2. 6 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 384
Provides content validation requirement that a node's author, language, taxonomy terms, or other 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.'));
    }
    if ($form_state['values']['unique_field_fields'][UNIQUE_FIELD_FIELDS_AUTHOR] === UNIQUE_FIELD_FIELDS_AUTHOR || isset($form_state['values']['unique_field_fields'][UNIQUE_FIELD_FIELDS_LANGUAGE]) && $form_state['values']['unique_field_fields'][UNIQUE_FIELD_FIELDS_LANGUAGE] === UNIQUE_FIELD_FIELDS_LANGUAGE) {
      form_set_error('unique_field_fields', t('The author and language fields are not supported within the scope of a single node.'));
    }
  }
}