Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions code/Control/UserDefinedFormController.php
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,14 @@ public function process($data, $form)
$session->set('userformssubmission'. $this->ID, $submittedForm->ID);
}

// If set, redirect to custom thank you page
if ($this->data()->ConfirmationPageID) {
$confirmationPage = $this->data()->ConfirmationPage();
if ($confirmationPage && $confirmationPage->exists()) {
Comment on lines +560 to +562
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ($this->data()->ConfirmationPageID) {
$confirmationPage = $this->data()->ConfirmationPage();
if ($confirmationPage && $confirmationPage->exists()) {
$confirmationPage = $this->data()->ConfirmationPage();
if ($confirmationPage && $confirmationPage->exists()) {

This is a simpler way to do the condition - though not by any means necessary for merging.

return $this->redirect($confirmationPage->Link() . $referrer);
}
}

return $this->redirect($this->Link('finished') . $referrer . $this->config()->get('finished_anchor'));
}

Expand Down
16 changes: 15 additions & 1 deletion code/UserForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
use SilverStripe\UserForms\Model\EditableFormField;
use SilverStripe\View\Requirements;
use SilverStripe\Core\Config\Configurable;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Forms\TreeDropdownField;

/**
* Defines the user defined functionality to be applied to any {@link DataObject}
Expand Down Expand Up @@ -117,6 +119,13 @@ trait UserForm
'Submissions' => SubmittedForm::class,
];

/**
* @var array
*/
private static $has_one = [
Comment on lines +122 to +125
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/**
* @var array
*/
private static $has_one = [
private static array $has_one = [

New API should be strongly typed instead of relying on PHPDocs.

'ConfirmationPage' => SiteTree::class,
];

private static $cascade_deletes = [
'EmailRecipients',
];
Expand Down Expand Up @@ -210,7 +219,12 @@ public function getCMSFields()
CheckboxField::create(
'DisableSaveSubmissions',
_t('SilverStripe\\UserForms\\Model\\UserDefinedForm.SAVESUBMISSIONS', 'Disable Saving Submissions to Server')
)
),
TreeDropdownField::create(
'ConfirmationPageID',
_t('SilverStripe\\UserForms\\Model\\UserDefinedForm.CONFIRMATIONPAGE', 'Custom confirmation page'),
SiteTree::class
),
Comment on lines +222 to +227
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This formfield should already be scaffolded as per SiteTree::scaffoldFormFieldForHasOne(). Is there a need to redeclare it here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing so allows the use of a new translation key.
There might be other ways of achieveing this that the author is unaware of.

]);
$editor->setRows(3);
$label->addExtraClass('left');
Expand Down
1 change: 1 addition & 0 deletions lang/ar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ ar:
ADDEMAILRECIPIENT: 'أضف متلقي البريد الإلكتروني'
CLASS_DESCRIPTION: 'يضيف استمارة مخصصة.'
CONFIGURATION: المواصفات
CONFIRMATIONPAGE: 'صفحة التأكيد المخصصة'
DESCRIPTION: 'يضيف استمارة مخصصة.'
EMAILADDRESS: 'البريد الإلكتروني'
EMAILBODY: هيئة
Expand Down
1 change: 1 addition & 0 deletions lang/bg_BG.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ bg_BG:
db_EmailSubject: 'Email Subject'
has_one_Form: Формуляр
SilverStripe\UserForms\Model\UserDefinedForm:
CONFIRMATIONPAGE: 'Потребителска страница за потвърждение'
EMAILSUBJECT: 'Email Subject'
FROMADDRESS: 'Send Email From'
HIDEFORMDATA: 'Hide Form Data from Email'
Expand Down
1 change: 1 addition & 0 deletions lang/da_DK.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ da_DK:
db_EmailSubject: 'Email Subject'
has_one_Form: Formular
SilverStripe\UserForms\Model\UserDefinedForm:
CONFIRMATIONPAGE: 'Brugerdefineret bekræftelsesside'
EMAILSUBJECT: 'Email Subject'
FROMADDRESS: 'Send Email From'
HIDEFORMDATA: 'Hide Form Data from Email'
Expand Down
1 change: 1 addition & 0 deletions lang/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ de:
ADDEMAILRECIPIENT: 'E-Mail-Empfänger hinzufügen'
CLEARBUTTON: Löschen
CONFIGURATION: Einstellungen
CONFIRMATIONPAGE: 'Benutzerdefinierte Bestätigungsseite'
DISABLECSRFSECURITYTOKEN: 'Deaktiviere CSRF-Token'
DISPLAYERRORMESSAGESATTOP: 'Fehlermeldungen über dem Formular anzeigen?'
EMAILADDRESS: E-Mail
Expand Down
1 change: 1 addition & 0 deletions lang/de_DE.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ de_DE:
CLASS_DESCRIPTION: 'Fügt ein anpassbares Formular hinzu.'
CLEARBUTTON: Löschen
CONFIGURATION: Konfiguration
CONFIRMATIONPAGE: 'Benutzerdefinierte Bestätigungsseite'
DESCRIPTION: 'Fügt ein anpassbares Formular hinzu.'
DISABLECSRFSECURITYTOKEN: 'Deaktiviere CSRF-Token'
DISPLAYERRORMESSAGESATTOP: 'Fehlermeldungen über dem Formular anzeigen?'
Expand Down
1 change: 1 addition & 0 deletions lang/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ en:
CLASS_DESCRIPTION: 'Adds a customizable form.'
CLEARBUTTON: Clear
CONFIGURATION: Configuration
CONFIRMATIONPAGE: 'Custom confirmation page'
DESCRIPTION: 'Adds a customizable form.'
DISABLEAUTHENICATEDFINISHACTION: 'Disable Authentication on finish action'
DISABLECSRFSECURITYTOKEN: 'Disable CSRF Token'
Expand Down
1 change: 1 addition & 0 deletions lang/eo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ eo:
CLASS_DESCRIPTION: 'Aldonas adapteblan formularon'
CLEARBUTTON: Vakigi
CONFIGURATION: Agordaro
CONFIRMATIONPAGE: 'Propra konfirma paĝo'
DESCRIPTION: 'Aldonas adapteblan formularon'
DISABLEAUTHENICATEDFINISHACTION: 'Malŝalti aŭtentigon de kompletiga ago'
DISABLECSRFSECURITYTOKEN: 'Malŝalti CSRF-ĵetonon'
Expand Down
1 change: 1 addition & 0 deletions lang/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ es:
has_one_Parent: Padre
SilverStripe\UserForms\Model\UserDefinedForm:
CLEARBUTTON: Limpiar
CONFIRMATIONPAGE: 'Página de confirmación personalizada'
EMAILADDRESS: 'Correo electrónico'
EMAILFROM: De
EMAILSUBJECT: 'Asunto del Email'
Expand Down
1 change: 1 addition & 0 deletions lang/es_ES.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ es_ES:
ADDEMAILRECIPIENT: 'Agregar destinatario de email'
CLASS_DESCRIPTION: 'Agrega un formulario personalizable.'
CONFIGURATION: Configuración
CONFIRMATIONPAGE: 'Página de confirmación personalizada'
DESCRIPTION: 'Agrega un formulario personalizable.'
EMAILBODY: Cuerpo
EMAILBODYHTML: Cuerpo
Expand Down
1 change: 1 addition & 0 deletions lang/fa_IR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ fa_IR:
SilverStripe\UserForms\Model\UserDefinedForm:
CLEARBUTTON: پاک‌کردن
CONFIGURATION: پیکربندی
CONFIRMATIONPAGE: 'صفحه تأیید سفارشی'
DISABLECSRFSECURITYTOKEN: 'غیر فعال کردن CSRF'
EMAILADDRESS: ایمیل
EMAILFROM: از
Expand Down
1 change: 1 addition & 0 deletions lang/fi_FI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ fi_FI:
CLASS_DESCRIPTION: 'Lisää kustomoitavan lomakkeen.'
CLEARBUTTON: Tyhjennä
CONFIGURATION: Asetukset
CONFIRMATIONPAGE: 'Mukautettu vahvistussivu'
DESCRIPTION: 'Lisää kustomoitavan lomakkeen.'
DISABLEAUTHENICATEDFINISHACTION: 'Poista Autentikointi viimeistelytoiminnosta'
DISABLECSRFSECURITYTOKEN: 'Poista CSRF Token'
Expand Down
1 change: 1 addition & 0 deletions lang/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ fr:
SilverStripe\UserForms\Model\UserDefinedForm:
ADDEMAILRECIPIENT: 'Ajouter un mail de destination'
CLEARBUTTON: Effacer
CONFIRMATIONPAGE: 'Page de confirmation personnalisée'
DISABLEAUTHENICATEDFINISHACTION: "Désactiver l'authentification à la fin de l'action"
DISABLECSRFSECURITYTOKEN: 'Désactiver le jeton CSRF'
DISPLAYERRORMESSAGESATTOP: "Afficher les messages d'erreur au dessus du formulaire"
Expand Down
1 change: 1 addition & 0 deletions lang/hr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,6 @@ hr:
SilverStripe\UserForms\Model\UserDefinedForm:
CLEARBUTTON: Očisti
CONFIGURATION: Konfiguracija
CONFIRMATIONPAGE: 'Stranica za potvrdu'
EMAILFROM: Od
PLURALNAME: 'Osnovne stranice'
1 change: 1 addition & 0 deletions lang/id.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ id:
db_Value: Nilai
has_one_Parent: Induk
SilverStripe\UserForms\Model\UserDefinedForm:
CONFIRMATIONPAGE: 'Halaman konfirmasi kustom'
EMAILFROM: Dari
EMAILSUBJECT: 'Subyek email'
PLURALNAME: 'Laman Dasar'
1 change: 1 addition & 0 deletions lang/it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ it:
CLASS_DESCRIPTION: 'Aggiungi un modulo personalizzabile.'
CLEARBUTTON: Azzera
CONFIGURATION: Configurazione
CONFIRMATIONPAGE: 'Pagina di conferma personalizzata'
DESCRIPTION: 'Aggiungi un modulo personalizzabile.'
DISABLEAUTHENICATEDFINISHACTION: "Disabilita autenticazione sull'azione finale"
DISABLECSRFSECURITYTOKEN: 'Disabilita token CSRF'
Expand Down
1 change: 1 addition & 0 deletions lang/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ ja:
db_Value: 数値
SilverStripe\UserForms\Model\UserDefinedForm:
CLEARBUTTON: クリア
CONFIRMATIONPAGE: 'カスタム確認ページ'
EMAILADDRESS: メール
EMAILBODY: ボディ
EMAILBODYHTML: ボディ
Expand Down
1 change: 1 addition & 0 deletions lang/mi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ mi:
ADDEMAILRECIPIENT: 'Tāpiri Kaiwhirhi Īmēra'
CLASS_DESCRIPTION: 'Ka tāpiri i te puka ka taea te whakarite.'
CONFIGURATION: Whirihoranga
CONFIRMATIONPAGE: 'Whārangi whakaū ritenga ake'
DESCRIPTION: 'Ka tāpiri i te puka ka taea te whakarite.'
EMAILADDRESS: Īmēra
EMAILBODY: Tinana
Expand Down
1 change: 1 addition & 0 deletions lang/nb_NO.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ nb_NO:
ADDEMAILRECIPIENT: 'Legg til e-post mottaker'
CLASS_DESCRIPTION: 'Legg til konfigurerbart skjema'
CONFIGURATION: Konfigurasjon
CONFIRMATIONPAGE: 'Egendefinert bekreftelsesside'
DESCRIPTION: 'Legg til konfigurerbart skjema'
EMAILADDRESS: Epost
EMAILFROM: Fra
Expand Down
1 change: 1 addition & 0 deletions lang/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ nl:
CLASS_DESCRIPTION: 'Zelf-instelbaar formulier.'
CLEARBUTTON: Wissen
CONFIGURATION: Configuratie
CONFIRMATIONPAGE: 'Aangepaste bevestigingspagina'
DESCRIPTION: 'Zelf-instelbaar formulier.'
DISABLEAUTHENICATEDFINISHACTION: 'Bedanktpagina toegankelijk maken zonder formulier-inzending'
DISABLECSRFSECURITYTOKEN: 'CSRF-token uitschakelen'
Expand Down
1 change: 1 addition & 0 deletions lang/pl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pl:
db_Title: Tytuł
SilverStripe\UserForms\Model\UserDefinedForm:
CLEARBUTTON: Wyczyść
CONFIRMATIONPAGE: 'Strona potwierdzenia'
EMAILFROM: Od
PLURALNAME: 'Podstawowe strony'
RECIPIENTS: Odbiorcy
1 change: 1 addition & 0 deletions lang/ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ ru:
SilverStripe\UserForms\Model\UserDefinedForm:
CLEARBUTTON: Сбросить
CONFIGURATION: Конфигурация
CONFIRMATIONPAGE: 'Пользовательская страница подтверждения'
EMAILFROM: От
EMAILSUBJECT: 'Тема письма'
PLURALNAME: 'Базовые страницы'
Expand Down
1 change: 1 addition & 0 deletions lang/sk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ sk:
CLASS_DESCRIPTION: 'Umožňuje vytvoriť užívateľom definovaný formulár.'
CLEARBUTTON: Vyčistiť
CONFIGURATION: Konfigurácia
CONFIRMATIONPAGE: 'Vlastná potvrdzovacia stránka'
DESCRIPTION: 'Umožňuje vytvoriť užívateľom definovaný formulár.'
DISABLEAUTHENICATEDFINISHACTION: 'Zakázať autentifikáciu po odoslaní formulára?'
DISABLECSRFSECURITYTOKEN: 'Zakázať CSRF token?'
Expand Down
1 change: 1 addition & 0 deletions lang/sl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ sl:
CLASS_DESCRIPTION: 'Doda prilagojen obrazec.'
CLEARBUTTON: Ponastavi
CONFIGURATION: Nastavitve
CONFIRMATIONPAGE: 'Stran za potrditev po meri'
DESCRIPTION: 'Doda prilagojen obrazec.'
DISABLEAUTHENICATEDFINISHACTION: 'Onemogoči avtentikacijo na koncu.'
DISABLECSRFSECURITYTOKEN: 'Onemogoči CSRF žeton'
Expand Down
1 change: 1 addition & 0 deletions lang/sv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ sv:
CLASS_DESCRIPTION: 'Lägger till ett konfigurerbart formulär'
CLEARBUTTON: Rensa
CONFIGURATION: Konfiguration
CONFIRMATIONPAGE: 'Anpassad bekräftelsesida'
DESCRIPTION: 'Lägger till ett konfigurerbart formulär'
DISABLECSRFSECURITYTOKEN: 'Inaktivera CSRF-tecken'
EMAILADDRESS: E-post
Expand Down
1 change: 1 addition & 0 deletions lang/zh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ zh:
CLASS_DESCRIPTION: 添加一个可定制的表格。
CLEARBUTTON: 清除
CONFIGURATION: 配置
CONFIRMATIONPAGE: '自定义确认页面'
DESCRIPTION: 添加一个可定制的表格。
EMAILADDRESS: 电子邮件
EMAILBODY: 正文
Expand Down