function tripal_pub_remote_validate_form_AGL

2.x tripal_pub.AGL.inc tripal_pub_remote_validate_form_AGL($form, $form_state)
3.x tripal_chado.pub_importer_AGL.inc tripal_pub_remote_validate_form_AGL($form, $form_state)
1.x AGL.inc tripal_pub_remote_validate_form_AGL($form, $form_state)

A hook for providing additional validation of importer setup form.

Parameters

$form: The Drupal form array

$form_state: The form state array

Return value

The form (drupal form api)

Related topics

File

tripal_pub/includes/importers/tripal_pub.AGL.inc, line 61
Importer for the USDA Agricultural Library (Agricola).

Code

function tripal_pub_remote_validate_form_AGL($form, $form_state) {
  $days = trim($form_state['values']["days"]);
  $num_criteria = $form_state['values']['num_criteria'];

  if ($days and !preg_match('/^\d\d\d\d$/', $days)) {
    form_set_error("days", "Please enter a four digit year.");
  }

  $num_ids = 0;
  for ($i = 1; $i <= $num_criteria; $i++) {
    $search_terms = trim($form_state['values']["search_terms-$i"]);
    $scope = $form_state['values']["scope-$i"];
    if ($scope == 'id' and !preg_match('/^AGL:\d+$/', $search_terms)) {
      form_set_error("search_terms-$i", "The AGL accession be a numeric value, prefixed with 'AGL:' (e.g. AGL:3890740).");
    }
    if ($scope == 'id') {
      $num_ids++;
    }
    if ($num_ids > 1) {
      form_set_error("search_terms-$i", "Unfortuantely, the AGL importer can only support a single accession at a time. Please remove the others.");
    }
  }
  return $form;
}