Commit 0db1c040 authored by lauriii's avatar lauriii

Issue #2954884 by msankhala: Cannot save theme settings form for themes...

Issue #2954884 by msankhala: Cannot save theme settings form for themes without logo or favicon features
parent 36d5f79d
......@@ -377,22 +377,23 @@ public function validateForm(array &$form, FormStateInterface $form_state) {
parent::validateForm($form, $form_state);
if ($this->moduleHandler->moduleExists('file')) {
$validators = ['file_validate_is_image' => []];
// Check for a new uploaded logo.
$file = _file_save_upload_from_form($form['logo']['settings']['logo_upload'], $form_state, 0);
if ($file) {
// Put the temporary file in form_values so we can save it on submit.
$form_state->setValue('logo_upload', $file);
if (isset($form['logo'])) {
$file = _file_save_upload_from_form($form['logo']['settings']['logo_upload'], $form_state, 0);
if ($file) {
// Put the temporary file in form_values so we can save it on submit.
$form_state->setValue('logo_upload', $file);
}
}
$validators = ['file_validate_extensions' => ['ico png gif jpg jpeg apng svg']];
// Check for a new uploaded favicon.
$file = _file_save_upload_from_form($form['favicon']['settings']['favicon_upload'], $form_state, 0);
if ($file) {
// Put the temporary file in form_values so we can save it on submit.
$form_state->setValue('favicon_upload', $file);
if (isset($form['favicon'])) {
$file = _file_save_upload_from_form($form['favicon']['settings']['favicon_upload'], $form_state, 0);
if ($file) {
// Put the temporary file in form_values so we can save it on submit.
$form_state->setValue('favicon_upload', $file);
}
}
// When intending to use the default logo, unset the logo_path.
......
......@@ -428,4 +428,17 @@ public function testInstallAndSetAsDefault() {
$this->assertTextPattern('/Bartik ' . preg_quote($version) . '\s{2,}\(default theme\)/');
}
/**
* Test the theme settings form when logo and favicon features are disabled.
*/
public function testThemeSettingsNoLogoNoFavicon() {
// Install theme with no logo and no favicon feature.
$this->container->get('theme_handler')->install(['test_theme_settings_features']);
// Visit this theme's settings page.
$this->drupalGet('admin/appearance/settings/test_theme_settings_features');
$edit = [];
$this->drupalPostForm('admin/appearance/settings/test_theme_settings_features', $edit, t('Save configuration'));
$this->assertText('The configuration options have been saved.');
}
}
test_theme_settings_features.settings:
type: theme_settings
label: 'Test theme settings'
name: Test features
type: theme
core: 8.x
description: 'Test theme to test theme settings with limited features.'
features:
- node_user_picture
- comment_user_picture
- comment_user_verification
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