protected function ScheduledUpdateTypeForm::createFieldMapElements in Scheduled Updates 8
Create form elements to update field map.
@internal param array $form @internal param $scheduled_update_type
Return value
array
1 call to ScheduledUpdateTypeForm::createFieldMapElements()
- ScheduledUpdateTypeForm::form in src/
Form/ ScheduledUpdateTypeForm.php - Gets the actual form array to be built.
File
- src/
Form/ ScheduledUpdateTypeForm.php, line 157 - Contains \Drupal\scheduled_updates\Form\ScheduledUpdateTypeForm.
Class
- ScheduledUpdateTypeForm
- Class ScheduledUpdateTypeForm.
Namespace
Drupal\scheduled_updates\FormCode
protected function createFieldMapElements() {
if ($this->entity
->isNew()) {
return [];
}
$field_map_help = 'Select the destination fields for this update type.' . ' Not all field have to have destinations if you using them for other purposes.';
$elements = [
'#type' => 'details',
'#title' => 'destination fields',
'#description' => $this
->t($field_map_help),
'#tree' => TRUE,
];
$source_fields = $this
->getSourceFields($this->entity);
$field_map = $this->entity
->getFieldMap();
foreach ($source_fields as $source_field_id => $source_field) {
$destination_fields_options = $this
->getDestinationFieldsOptions($this->entity
->getUpdateEntityType(), $source_field);
$elements[$source_field_id] = [
'#type' => 'select',
'#title' => $source_field
->label(),
'#options' => [
'' => $this
->t("(Not mapped)"),
] + $destination_fields_options,
'#default_value' => isset($field_map[$source_field_id]) ? $field_map[$source_field_id] : '',
];
}
return $elements;
}