Commit f70bf712 authored by alexpott's avatar alexpott

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

parent 49dc0872
......@@ -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'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment