From a87ddeb572292f3ef4f8d33183025c7d8cc8cfeb Mon Sep 17 00:00:00 2001
From: Alex Barth <alex_b@53995.no-reply.drupal.org>
Date: Fri, 10 Sep 2010 16:00:46 +0000
Subject: [PATCH] Cleanup mapping form generation.

---
 feeds_ui/feeds_ui.admin.inc | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/feeds_ui/feeds_ui.admin.inc b/feeds_ui/feeds_ui.admin.inc
index a6a82777..d21a7804 100644
--- a/feeds_ui/feeds_ui.admin.inc
+++ b/feeds_ui/feeds_ui.admin.inc
@@ -492,6 +492,7 @@ function feeds_ui_mapping_form(&$form_state, $importer) {
 
   $form = array();
   $form['#importer'] = $importer;
+  $form['#mappings'] = $mappings = $importer->processor->getMappings();
   $form['help']['#value'] = feeds_ui_mapping_help();
 
   // Get mapping sources from parsers and targets from processor, format them
@@ -514,6 +515,7 @@ function feeds_ui_mapping_form(&$form_state, $importer) {
     $legend['targets'][$k]['description']['#value'] = empty($target['description']) ? '' : $target['description'];
   }
 
+  // Legend explaining source and target elements.
   $form['legendset'] = array(
     '#type' => 'fieldset',
     '#title' => t('Legend'),
@@ -524,20 +526,16 @@ function feeds_ui_mapping_form(&$form_state, $importer) {
   $form['legendset']['legend'] = $legend;
 
   // Add unique and remove forms to mappings.
-  $mappings = $importer->processor->getMappings();
   $form['unique_flags'] = $form['remove_flags'] = array(
     '#tree' => TRUE,
   );
-
   if (is_array($mappings)) {
     foreach ($mappings as $i => $mapping) {
       $param = array(
         'processor' => $importer->processor,
         'mapping' => $mapping,
       );
-
       if (isset($targets[$mapping['target']]['optional_unique']) && $targets[$mapping['target']]['optional_unique'] === TRUE) {
-
         $form['unique_flags'][$i] = array(
           '#type' => 'checkbox',
           '#default_value' => !empty($mapping['unique']),
@@ -553,9 +551,7 @@ function feeds_ui_mapping_form(&$form_state, $importer) {
     }
   }
 
-  $form['#mappings'] = $mappings;
-  $form['#targets'] = $targets;
-  if ($sources) {
+  if ($source_options) {
     $form['source'] = array(
       '#type' => 'select',
       '#options' => array('' => t('Select a source')) + $source_options,
-- 
GitLab