function tripal_views_integration_form_validate

2.x tripal_views_integration_UI.inc tripal_views_integration_form_validate($form, &$form_state)
1.x tripal_views_integration.inc tripal_views_integration_form_validate($form, &$form_state)

Purpose: validates the tripal_views_integration_form after submission

Parameters

$form: The form object which is passed automatically by drupal

$form_state: The form state pbject which is passed automatically by drupal

Related topics

File

tripal_views/includes/tripal_views_integration_UI.inc, line 1120
Functions related to the UI for integrating tables with views

Code

function tripal_views_integration_form_validate($form, &$form_state) {
  $name_array = explode(" ", $form_state['values']['row_name']);
  $mview_id = $form_state['values']['mview_id'];
  $table_name = $form_state['values']['table_name'];

  //  if (count($name_array) > 1) {
  //    form_set_error($form_state['values']['row_name'], 'The View type name must be a single word only.');
  //  }
  if ($mview_id and $table_name) {
    form_set_error('mview_id', 'Please select either a materialized view or a Chado table but not both');
  }
  if (!$mview_id and !$table_name) {
    form_set_error('mview_id', 'Please select either a materialized view or a Chado table');
  }

  // Ensure that users don't override the default integrations
  if ($form_state['values']['row_priority'] >= 9) {
    form_set_error('row_priority', 'A priority of 10 or 9 is reserved for default tripal '
      . 'views integrations created by core modules. Please set the priority between '
      . '0 and -10 to ensure your changes are used rather over the defaults.');
  }

  // Check that if some fields for a new join are entered, all of them are
  if (!empty($form_state['values']['new_join_base_field'])
   OR !empty($form_state['values']['new_join_left_table'])
     OR !empty($form_state['values']['new_join_left_field'])) {
    if (!(!empty($form_state['values']['new_join_base_field'])
      AND !empty($form_state['values']['new_join_left_table'])
      AND !empty($form_state['values']['new_join_left_field']))) {
      form_set_error('new_join_base_field', 'You need to select the Base Column, Left Table and Left Column to create a new join');
    }
  }
}