You are here

function feeds_ui_mapping_form_submit in Feeds 6

Same name and namespace in other branches
  1. 8.2 feeds_ui/feeds_ui.admin.inc \feeds_ui_mapping_form_submit()
  2. 7.2 feeds_ui/feeds_ui.admin.inc \feeds_ui_mapping_form_submit()
  3. 7 feeds_ui/feeds_ui.admin.inc \feeds_ui_mapping_form_submit()

Submit handler for save button on feeds_ui_mapping_form().

File

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

Code

function feeds_ui_mapping_form_submit($form, &$form_state) {
  $processor = $form['#importer']->processor;

  // We may set some unique flags to mappings that we remove in the subsequent
  // step, that's fine.
  $mappings = $form['#mappings'];
  if (isset($form_state['values']['unique_flags'])) {
    foreach ($form_state['values']['unique_flags'] as $k => $v) {
      $mappings[$k]['unique'] = $v;
    }
  }
  if (!empty($form_state['values']['remove_flags'])) {
    foreach ($form_state['values']['remove_flags'] as $k => $v) {
      if ($v) {
        unset($mappings[$k]);
      }
    }

    // Keep our keys clean.
    $mappings = array_values($mappings);
  }
  $processor
    ->addConfig(array(
    'mappings' => $mappings,
  ));
  $processor
    ->save();
  drupal_set_message(t('Your changes have been saved.'));
}