You are here

function bpc_display_settings_form_validate in Commerce Bulk Product Creation 7.2

Form validation handler for bpc_display_settings_form().

File

modules/bpc_display/bpc_display.admin.inc, line 161
Adminstration pages for the Commerce BPC display node module.

Code

function bpc_display_settings_form_validate($form, &$form_state) {
  $fv =& $form_state['values'];
  switch ($fv['creation_method']) {
    case 'auto':
    case 'onetoone':

      // Notify the user if there is no content type available.
      if (!empty($fv['no_content_types_available'])) {
        form_set_error('auto_content_type', 'You cannot activate auto-creation of display nodes if there are no appropriate display node types. See below for details.');
      }

      // Make sure all the required fields have values.
      if (empty($fv['auto_content_type']) || $fv['auto_content_type'] == '_none') {
        form_set_error('auto_content_type', 'You have to specify a content type to automatically create display nodes.');
      }
      if (empty($fv['auto_node_title_pattern'])) {
        form_set_error('auto_node_title_pattern', 'For auto-creation of display nodes to work, you have to specify a pattern for the node title.');
      }
      if ($fv['auto_redirect'] == 'custom') {
        if (empty($fv['auto_redirect_custom'])) {
          form_set_error('auto_redirect', 'Please specify a custom redirect location.');
        }
        elseif (!drupal_valid_path($fv['auto_redirect_custom'])) {
          form_set_error('auto_redirect_custom', 'Please specify a valid path as custom redirect location');
        }
      }
      break;
  }
}