Skip to content
Snippets Groups Projects

Reset pre chat values on save to make sure the keys are in sequential order.

All threads resolved!
Files
2
@@ -223,7 +223,8 @@ class SalesforceMfw extends BlockBase implements ContainerFactoryPluginInterface
$this->configuration['utility_bootstrap'] = $form_state->getValue('utility_bootstrap');
$this->configuration['language'] = $form_state->getValue('language');
$this->configuration['allow_token_replacement'] = $form_state->getValue('allow_token_replacement');
$this->configuration['prechat_fields'] = $form_state->getValue(['fields_container', 'prechat_fields']) ?: [];
$prechat_fields = $form_state->getValue(['fields_container', 'prechat_fields']);
$this->configuration['prechat_fields'] = is_array($prechat_fields) ? array_values($prechat_fields) : [];
parent::submitConfigurationForm($form, $form_state);
}
@@ -279,7 +280,7 @@ class SalesforceMfw extends BlockBase implements ContainerFactoryPluginInterface
];
// Update the form state with the modified fields.
$form_state->set('prechat_fields', array_values($fields));
$form_state->set('prechat_fields', $fields);
// Rebuild the form to reflect the updated fields.
$form_state->setRebuild(TRUE);
Loading