You are here

function feeds_ui_mapping_form_validate in Feeds 8.2

Same name and namespace in other branches
  1. 7.2 feeds_ui/feeds_ui.admin.inc \feeds_ui_mapping_form_validate()

Validation handler for feeds_ui_mapping_form().

File

feeds_ui/feeds_ui.admin.inc, line 685
Contains all page callbacks, forms and theming functions for Feeds administrative pages.

Code

function feeds_ui_mapping_form_validate($form, &$form_state) {
  if (empty($form_state['values']['source']) xor empty($form_state['values']['target'])) {

    // Check triggering_element here so we can react differently for ajax
    // submissions.
    switch ($form_state['triggering_element']['#name']) {

      // Regular form submission.
      case 'op':
        if (empty($form_state['values']['source'])) {
          form_error($form['source'], t('You must select a mapping source.'));
        }
        else {
          form_error($form['target'], t('You must select a mapping target.'));
        }
        break;

      // Be more relaxed on ajax submission.
      default:
        form_set_value($form['source'], '', $form_state);
        form_set_value($form['target'], '', $form_state);
        break;
    }
  }
}