You are here

function purl_form_validate in Persistent URL 6

Same name and namespace in other branches
  1. 7 purl.module \purl_form_validate()

Validation handler for purl_form().

1 string reference to 'purl_form_validate'
purl_form in ./purl.module
Generates a persistent url form element that can be dropped into a FormAPI form array. Includes validation, but insert/update must be handled by the implementing submit handler.

File

./purl.module, line 734

Code

function purl_form_validate($form) {
  if (!$form['value']['#required'] && empty($form['value']['#value'])) {
    return TRUE;
  }
  $modifier = array(
    'provider' => $form['provider']['#value'],
    'value' => $form['value']['#value'],
    'id' => $form['id']['#value'],
  );
  if (!purl_validate($modifier)) {
    form_set_error($form['#parents'][0], t('There was an error registering the value "@value". It is either invalid or is already taken. Please choose another.', array(
      '@value' => $form['value']['#value'],
    )));
    return FALSE;
  }
  else {
    return TRUE;
  }
}