You are here

function quicktabs_callback_element_validate in Quick Tabs 7.3

1 string reference to 'quicktabs_callback_element_validate'
QuickCallbackContent::optionsForm in plugins/QuickCallbackContent.inc
Method for returning the form elements to display for this tab type on the admin form.

File

./quicktabs.admin.inc, line 467
Provides the Quicktabs administrative interface.

Code

function quicktabs_callback_element_validate($element, &$form_state, $form) {

  // We can tell which tab delta the element is for from the element's #parents
  // property, which is an array based on the tree structure.
  $delta = $element['#parents'][1];
  if ($form_state['values']['tabs'][$delta]['type'] == 'callback') {
    if (empty($element['#value']) || url_is_external($element['#value'])) {
      form_error($element, t('You must specify a valid path.'));
    }
    if (strpos($element['#value'], '%') === 0) {
      form_error($element, t('"%" may not be used for the first segment of a path.'));
    }

    // automatically remove '/' from path.
    $form_state['values']['tabs'][$delta]['callback']['path'] = trim($form_state['values']['tabs'][$delta]['callback']['path'], '/');
  }
}