public function ParserBase::mappingFormAlter in Feeds 8.3
Alter mapping form.
Parameters
array $form: The mapping form definition.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the mapping form.
Overrides MappingPluginFormInterface::mappingFormAlter
File
- src/
Feeds/ Parser/ ParserBase.php, line 39
Class
- ParserBase
- Base class for Feeds parsers.
Namespace
Drupal\feeds\Feeds\ParserCode
public function mappingFormAlter(array &$form, FormStateInterface $form_state) {
// Override the label for adding new sources, so it is more clear what the
// source value represents.
$source_label = $this
->configSourceLabel();
$description = $this
->configSourceDescription();
if ($source_label || $description) {
foreach (Element::children($form['mappings']) as $i) {
if (!isset($form['mappings'][$i]['map'])) {
continue;
}
foreach (Element::children($form['mappings'][$i]['map']) as $subtarget) {
if ($source_label) {
$form['mappings'][$i]['map'][$subtarget]['select']['#options']['__new'] = $this
->t('New @label...', [
'@label' => $source_label,
]);
}
if ($description) {
$form['mappings'][$i]['map'][$subtarget]['__new']['value']['#description'] = $description;
}
}
}
}
}