You are here

function flag_lists_template_validate in Flag Lists 7

Same name and namespace in other branches
  1. 6 flag_lists.module \flag_lists_template_validate()
  2. 7.3 flag_lists.module \flag_lists_template_validate()
1 string reference to 'flag_lists_template_validate'
flag_lists_form_alter in ./flag_lists.module
Implementation of hook_form_alter().

File

./flag_lists.module, line 597
The Flag Lists module.

Code

function flag_lists_template_validate($form, &$form_state) {
  $types = array_filter($form_state['values']['types']);
  $errors = array();
  foreach ($types as $type) {
    $result = db_select('flag_lists_types', 'f')
      ->fields('f')
      ->condition('type', $type)
      ->condition('name', $form_state['values']['name'], '<>')
      ->execute();
    foreach ($result as $errors) {
      $content_types[] = $errors->type;
      $templates[] = $errors->name;
    }
  }
  if (isset($content_types) && count($content_types)) {
    $content_types = implode(', ', $content_types);
    $templates = implode(', ', array_unique($templates));
    form_set_error('types', t('The flaggable content type(s) "@type" is(are) already assigned to the template(s) "@template." A content type may be assigned to only one template. To reassign a content type you must first remove its other assignment.', array(
      '@type' => $content_types,
      '@template' => $templates,
    )));
  }
}