function tripal_pub_remote_validate_form_PMID

2.x tripal_pub.PMID.inc tripal_pub_remote_validate_form_PMID($form, $form_state)
3.x tripal_chado.pub_importer_PMID.inc tripal_pub_remote_validate_form_PMID($form, $form_state)
1.x PMID.inc tripal_pub_remote_validate_form_PMID($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.PMID.inc, line 50
This file provides support for importing and parsing of results from the NCBI PubMed database. The functions here are used by both the publication importer setup form and the publication importer.

Code

function tripal_pub_remote_validate_form_PMID($form, $form_state) {
  $num_criteria = $form_state['values']['num_criteria'];

  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('/^PMID:\d+$/', $search_terms)) {
      form_set_error("search_terms-$i", "The PubMed accession must be a numeric value, prefixed with 'PMID:' (e.g. PMID:23024789).");
    }
  }
  return $form;
}