Skip to content

Commit a48490a

Browse files
committed
Show flash messages on saving settings
1 parent cb63b3b commit a48490a

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/Controller/SettingsController.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
use Symfony\Component\Routing\Attribute\Route;
3434
use Symfony\Contracts\Cache\TagAwareCacheInterface;
3535

36+
use function Symfony\Component\Translation\t;
37+
3638
class SettingsController extends AbstractController
3739
{
3840
public function __construct(private readonly SettingsManagerInterface $settingsManager, private readonly SettingsFormFactoryInterface $settingsFormFactory)
@@ -63,11 +65,17 @@ public function systemSettings(Request $request, TagAwareCacheInterface $cache):
6365

6466
//It might be possible, that the tree settings have changed, so clear the cache
6567
$cache->invalidateTags(['tree_treeview', 'sidebar_tree_update']);
68+
69+
$this->addFlash('success', t('settings.flash.saved'));
70+
}
71+
72+
if ($form->isSubmitted() && !$form->isValid()) {
73+
$this->addFlash('error', t('settings.flash.invalid'));
6674
}
6775

6876
//Render the form
6977
return $this->render('settings/settings.html.twig', [
7078
'form' => $form
7179
]);
7280
}
73-
}
81+
}

translations/messages.en.xlf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13033,5 +13033,17 @@ Please note, that you can not impersonate a disabled user. If you try you will g
1303313033
<target>The value of this parameter can be overridden by setting the environment variable "%env%".</target>
1303413034
</segment>
1303513035
</unit>
13036+
<unit id="boWkQh7" name="settings.flash.saved">
13037+
<segment>
13038+
<source>settings.flash.saved</source>
13039+
<target>Settings saved successfully.</target>
13040+
</segment>
13041+
</unit>
13042+
<unit id="tEYWrWD" name="settings.flash.invalid">
13043+
<segment>
13044+
<source>settings.flash.invalid</source>
13045+
<target>Settings are invalid. Please check your input!</target>
13046+
</segment>
13047+
</unit>
1303613048
</file>
1303713049
</xliff>

0 commit comments

Comments
 (0)