Skip to content
Snippets Groups Projects
Commit f70bf712 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2536906 by aspilicious: Warning when saving third party settings while no settings available

parent 49dc0872
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -567,7 +567,7 @@ protected function copyFormValuesToEntity(EntityInterface $entity, array $form,
if ($form_state->get('plugin_settings_update') === $field_name) {
// Only store settings actually used by the selected plugin.
$default_settings = $this->pluginManager->getDefaultSettings($options['type']);
$options['settings'] = array_intersect_key($values['settings_edit_form']['settings'], $default_settings);
$options['settings'] = isset($values['settings_edit_form']['settings']) ? array_intersect_key($values['settings_edit_form']['settings'], $default_settings) : [];
$options['third_party_settings'] = isset($values['settings_edit_form']['third_party_settings']) ? $values['settings_edit_form']['third_party_settings'] : [];
$form_state->set('plugin_settings_update', NULL);
}
......
......@@ -163,6 +163,11 @@ function testFormatterUI() {
$edit = array('fields[field_test][type]' => 'field_no_settings', 'refresh_rows' => 'field_test');
$this->drupalPostAjaxForm(NULL, $edit, array('op' => t('Refresh')));
$this->assertFieldByName('field_test_settings_edit');
// Make sure we can save the third party settings when there are no settings available
$this->drupalPostAjaxForm(NULL, array(), "field_test_settings_edit");
$this->drupalPostAjaxForm(NULL, $edit, "field_test_plugin_settings_update");
// Uninstall the module providing third party settings and ensure the button
// is no longer there.
\Drupal::service('module_installer')->uninstall(array('field_third_party_test'));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment