You are here

function tft_add_term_form_validate in Taxonomy File Tree 7

Same name and namespace in other branches
  1. 7.2 includes/tft.pages.inc \tft_add_term_form_validate()

Validation callback.

See also

tft_add_term_form()

File

./tft.admin.inc, line 379

Code

function tft_add_term_form_validate($form, &$form_state) {

  // If the user can only add terms to an OG term
  if (!user_access(TFT_ADD_TERMS)) {
    if (!tft_term_access($form_state['values']['parent'])) {
      form_set_error('name');
      drupal_set_message(t("You must select a parent folder that is part of a group you're a member of."), 'error');
      if ($_GET['destination']) {
        drupal_goto(urldecode($_GET['destination']));
      }
      else {
        drupal_goto();
      }
      exit;
    }
  }

  // Check for forbidden characters
  if (strpos($form_state['values']['name'], ',') !== FALSE || strpos($form_state['values']['name'], '+') !== FALSE) {
    form_set_error('name', t("The following characters are not allowed: ',' (comma) and +"));
  }
}