You are here

function purl_admin_form_key_validate in Persistent URL 6

Same name and namespace in other branches
  1. 7 purl.admin.inc \purl_admin_form_key_validate()

Validate a key element and move its value to the correct key if validated.

2 string references to 'purl_admin_form_key_validate'
purl_pair::admin_form in includes/purl_pair.inc
Allow extension of the admin setup form.
purl_querystring::admin_form in includes/purl_querystring.inc
Allow extension of the admin setup form.

File

./purl.admin.inc, line 102
Admin pages for the purl module.

Code

function purl_admin_form_key_validate(&$element, &$form_state) {

  // Check for string identifier sanity
  if (!empty($element['#value'])) {
    if (!preg_match('!^[A-Za-z0-9_-]+$!', $element['#value'])) {
      form_set_error($element['#name'], t('The key may only consist of letters, numbers, dashes and underscores.'));
    }
    else {
      $form_state['values']["purl_method_{$element['#provider_id']}_key"] = $element['#value'];
    }
  }
  unset($form_state['values'][$element['#name']]);
}