public function NewickImporter::formValidate

3.x NewickImporter.inc public NewickImporter::formValidate($form, &$form_state)

Overrides TripalImporter::formValidate

See also

TripalImporter::formValidate()

File

tripal_chado/includes/TripalImporter/NewickImporter.inc, line 174

Class

NewickImporter

Code

public function formValidate($form, &$form_state) {

  $values = $form_state['values'];

  $options =[
  'name' trim($values["tree_name"])
    'description' trim($values["description"])
    'analysis_id' $values["analysis_id"]
    'leaf_type' $values["leaf_type"]
    'tree_file' $this->arguments['files'][0]['file_path']
    'format' 'newick'
    'dbxref' trim($values["dbxref"])
    'match' $values["match"]
    'name_re' $values["name_re"]
    ];

  $errors =[];
  $warnings =[];

  chado_validate_phylotree('insert', $options, $errors, $warnings);

  // Now set form errors if any errors were detected.
  if (count($errors) > 0) {
    foreach ($errors as $field => $message) {
      if ($field == 'name') {
        $field = 'tree_name';
      }
      form_set_error($field, $message);
    }
  }
  // Add any warnings if any were detected
  if (count($warnings) > 0) {
    foreach ($warnings as $field => $message) {
      drupal_set_message($message, 'warning');
    }
  }
}