Same name and namespace in other branches
  1. 7.x-3.x quicktabs.admin.inc \quicktabs_callback_element_validate() 1 comment
1 string reference to 'quicktabs_callback_element_validate'
QuickCallbackContent::optionsForm in src/Plugin/QuickContent/QuickCallbackContent.php
Method for returning the form elements to display for this tab type on the admin form.

File

./quicktabs.admin.inc, line 402

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'], '/');
    }
}