Problem/Motivation
Whenever saving the mapping fields, it clears the saved values for the "Record Types to Request" setting.
Steps to reproduce
- Create a mapping to SF Contact
- Set and save the "Record Types to Request"
- Switch to the Fields tab and save
- Switch back to the Settings tab and the previous settings are no longer saved
Proposed resolution
Move the buildEntity method from SalesforceMappingFormBase to SalesforceMappingFormCrudBase.
SalesforceMappingFieldsForm extends SalesforceMappingFormBase, therefore whenever saving the fields form, it resets the record type.
/**
* {@inheritdoc}
*/
public function buildEntity(array $form, FormStateInterface $form_state) {
$entity = parent::buildEntity($form, $form_state);
$record_types = $form_state->getValue('pull_record_type_filter');
if (!empty($record_types)) {
$record_types = array_filter($record_types);
if (!empty($record_types)) {
$record_types = array_values($record_types);
}
}
$entity->set('pull_record_type_filter', $record_types ?? []);
return $entity;
}
Remaining tasks
Review patch and test.
Comments
Comment #2
bkildow commentedThe patch here works for me!
Comment #5
aaronbaumanCommited, thanks