diff --git a/plugins/EmailNotifications/EmailNotifications.php b/plugins/EmailNotifications/EmailNotifications.php index 412c707336..daa180ad37 100644 --- a/plugins/EmailNotifications/EmailNotifications.php +++ b/plugins/EmailNotifications/EmailNotifications.php @@ -39,7 +39,8 @@ class EmailNotifications extends Plugin { public function onAddNotificationTransport(&$form_defs): bool { - $form_defs['email'] = $form_defs['placeholder']; + $form_defs['email'] = $form_defs['placeholder']; + $form_defs['email'][] = $form_defs['placeholder']['save']('Email', 'save_email'); unset($form_defs['email']['post_on_status_change']); return Event::next; } diff --git a/plugins/XMPPNotifications/XMPPNotifications.php b/plugins/XMPPNotifications/XMPPNotifications.php index eae71795fe..4ea5029630 100644 --- a/plugins/XMPPNotifications/XMPPNotifications.php +++ b/plugins/XMPPNotifications/XMPPNotifications.php @@ -39,7 +39,8 @@ class XMPPNotifications extends Plugin { public function onAddNotificationTransport(&$form_defs): bool { - $form_defs['xmpp'] = $form_defs['placeholder']; + $form_defs['xmpp'] = $form_defs['placeholder']; + $form_defs['xmpp'][] = $form_defs['placeholder']['save']('XMMP', 'save_xmpp'); return Event::next; } } diff --git a/src/Controller/UserPanel.php b/src/Controller/UserPanel.php index 073e534729..2c4b96a88d 100644 --- a/src/Controller/UserPanel.php +++ b/src/Controller/UserPanel.php @@ -177,12 +177,24 @@ class UserPanel extends AbstractController } } + $form_defs['placeholder']['save'] = fn(string $transport, string $form_name) => + [$form_name, SubmitType::class, + ['label' => _m('Save notification settings for {transport}', ['transport' => $transport])]]; + Event::handle('AddNotificationTransport', [&$form_defs]); unset($form_defs['placeholder']); $tabbed_forms = []; foreach ($form_defs as $transport_name => $f) { - $tabbed_forms[$transport_name] = Form::create($f); + unset($f['save']); + $form = Form::create($f); + $tabbed_forms[$transport_name] = $form; + + $form->handleRequest($request); + if ($form->isSubmitted() && $form->isValid()) { + $data = $form->getData(); + dd($data, $transport_name); + } } $tabbed_forms = F\map($tabbed_forms, function ($f) {