function feeds_tamper_form_feeds_ui_mapping_form_alter in Feeds Tamper 6
Same name and namespace in other branches
- 7 feeds_tamper.inc \feeds_tamper_form_feeds_ui_mapping_form_alter()
Implementation of hook_form_feeds_ui_mapping_form_alter().
This is an interesting bit of work. Each source name has to be unique, but we have no idea how many to create with feeds_tamper_feeds_parser_sources_alter() because we don't know how many targets there are going to be.
The solution is to keep track in the form how many have been added.
File
- ./
feeds_tamper.inc, line 252 - Version agnostic parts of feeds_tamper.module.
Code
function feeds_tamper_form_feeds_ui_mapping_form_alter(&$form, &$form_state) {
// Don't alter the form for parsers that use manual input.
if ($form['source']['#type'] == 'textfield') {
return;
}
$newest_source = NULL;
foreach ($form['#mappings'] as $mapping) {
if (strpos($mapping['source'], 'Blank source ') === 0) {
$newest_source = $mapping['source'];
}
}
if (!empty($newest_source)) {
list(, , $count) = explode(' ', $newest_source);
unset($form['source']['#options']['Blank source 1']);
$form['source']['#options']['Blank source ' . ++$count] = 'Blank source';
}
else {
$form['source']['#options']['Blank source 1'] = 'Blank source';
}
}