You are here

function patterns_lab_validate in Patterns 7

Same name and namespace in other branches
  1. 7.2 includes/forms/lab.inc \patterns_lab_validate()

Checks if the patterns directory is ready and if the file name for exported patterns is valid.

_state

Parameters

$form:

File

includes/forms/lab.inc, line 123
Functions related to exporting patterns.

Code

function patterns_lab_validate($form, &$form_state) {
  if (!isset($form_state['values']['patterns_table'])) {
    form_set_error('patterns_table', t('An error has occurred'));
  }
  if (array_sum($form_state['values']['patterns_table']) === 0) {
    form_set_error('patterns_table', t('No pattern selected.'));
  }
  if (!isset($form_state['values']['mode']) || !patterns_lab_is_valid_export_mode($form_state['values']['mode'])) {
    form_set_error('mode', t('Please select a valid include mode option'));
  }
  if (!isset($form_state['values']['to'])) {
    form_set_error('to', t('Please select a valid action for the export'));
  }
  if (!patterns_parser_exists($form_state['values']['format'])) {
    form_set_error('format', t('The pattern format seems to be invalid.'));
  }
  if ($form_state['values']['to'] === PATTERNS_EXPORT_TO_DB) {
    _patterns_import_check_name($form_state['values']['export_name']);
  }
  elseif (empty($form_state['values']['export_name'])) {
    $form_state['values']['export_name'] = 'pattern';
  }
  return TRUE;
}