Skip to content
Snippets Groups Projects
Commit a87ddeb5 authored by Alex Barth's avatar Alex Barth
Browse files

Cleanup mapping form generation.

parent 851580a3
No related branches found
No related tags found
No related merge requests found
...@@ -492,6 +492,7 @@ function feeds_ui_mapping_form(&$form_state, $importer) { ...@@ -492,6 +492,7 @@ function feeds_ui_mapping_form(&$form_state, $importer) {
$form = array(); $form = array();
$form['#importer'] = $importer; $form['#importer'] = $importer;
$form['#mappings'] = $mappings = $importer->processor->getMappings();
$form['help']['#value'] = feeds_ui_mapping_help(); $form['help']['#value'] = feeds_ui_mapping_help();
// Get mapping sources from parsers and targets from processor, format them // Get mapping sources from parsers and targets from processor, format them
...@@ -514,6 +515,7 @@ function feeds_ui_mapping_form(&$form_state, $importer) { ...@@ -514,6 +515,7 @@ function feeds_ui_mapping_form(&$form_state, $importer) {
$legend['targets'][$k]['description']['#value'] = empty($target['description']) ? '' : $target['description']; $legend['targets'][$k]['description']['#value'] = empty($target['description']) ? '' : $target['description'];
} }
// Legend explaining source and target elements.
$form['legendset'] = array( $form['legendset'] = array(
'#type' => 'fieldset', '#type' => 'fieldset',
'#title' => t('Legend'), '#title' => t('Legend'),
...@@ -524,20 +526,16 @@ function feeds_ui_mapping_form(&$form_state, $importer) { ...@@ -524,20 +526,16 @@ function feeds_ui_mapping_form(&$form_state, $importer) {
$form['legendset']['legend'] = $legend; $form['legendset']['legend'] = $legend;
// Add unique and remove forms to mappings. // Add unique and remove forms to mappings.
$mappings = $importer->processor->getMappings();
$form['unique_flags'] = $form['remove_flags'] = array( $form['unique_flags'] = $form['remove_flags'] = array(
'#tree' => TRUE, '#tree' => TRUE,
); );
if (is_array($mappings)) { if (is_array($mappings)) {
foreach ($mappings as $i => $mapping) { foreach ($mappings as $i => $mapping) {
$param = array( $param = array(
'processor' => $importer->processor, 'processor' => $importer->processor,
'mapping' => $mapping, 'mapping' => $mapping,
); );
if (isset($targets[$mapping['target']]['optional_unique']) && $targets[$mapping['target']]['optional_unique'] === TRUE) { if (isset($targets[$mapping['target']]['optional_unique']) && $targets[$mapping['target']]['optional_unique'] === TRUE) {
$form['unique_flags'][$i] = array( $form['unique_flags'][$i] = array(
'#type' => 'checkbox', '#type' => 'checkbox',
'#default_value' => !empty($mapping['unique']), '#default_value' => !empty($mapping['unique']),
...@@ -553,9 +551,7 @@ function feeds_ui_mapping_form(&$form_state, $importer) { ...@@ -553,9 +551,7 @@ function feeds_ui_mapping_form(&$form_state, $importer) {
} }
} }
$form['#mappings'] = $mappings; if ($source_options) {
$form['#targets'] = $targets;
if ($sources) {
$form['source'] = array( $form['source'] = array(
'#type' => 'select', '#type' => 'select',
'#options' => array('' => t('Select a source')) + $source_options, '#options' => array('' => t('Select a source')) + $source_options,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment