Skip to content

Commit

Permalink
Allow redirect override
Browse files Browse the repository at this point in the history
  • Loading branch information
spotbot2k committed Aug 3, 2022
1 parent 0ed2f8c commit 48cbca4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
30 changes: 21 additions & 9 deletions src/Document/Areabrick/SimpleForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function getEditableDialogBoxConfiguration(Editable $area, ?Info $info):
'items' => [
[
'type' => 'relation',
'label' => $this->translator->trans('pimcore_simple_forms.be.selected_form_object'),
'label' => $this->translator->trans('pimcore_simple_forms.fe.selected_form_object'),
'name' => 'formObject',
'config' => [
'types' => ['object'],
Expand All @@ -74,6 +74,16 @@ public function getEditableDialogBoxConfiguration(Editable $area, ?Info $info):
'width' => 350,
],
],
[
'type' => 'relation',
'label' => $this->translator->trans('pimcore_simple_forms.fe.selected_form_success_redirection'),
'name' => 'successRedirection',
'config' => [
'types' => ['document'],
'subtypes' => ['page', 'snippet'],
'width' => 350,
],
],
],
]);

Expand All @@ -83,6 +93,7 @@ public function getEditableDialogBoxConfiguration(Editable $area, ?Info $info):
public function action(Info $info): ?Response
{
$formObject = $this->getDocumentEditable($info->getDocument(), 'relation', 'formObject')->getElement();
$documentOnSuccess = $this->getDocumentEditable($info->getDocument(), 'relation', 'successRedirection')->getElement();
$info->setParam('snippet', null);

if (!is_null($formObject)) {
Expand Down Expand Up @@ -119,14 +130,15 @@ public function action(Info $info): ?Response
}

$this->dispatcher->dispatch(new PostSendMailEvent($formObject, $params), PostSendMailEvent::NAME);
$documentOnSuccess = $formObject->getSuccessRedirect();

if (!is_null($documentOnSuccess)) {
if ($documentOnSuccess instanceof Page) {
return new RedirectResponse($documentOnSuccess->getFullPath());
} elseif ($documentOnSuccess instanceof Snippet) {
$info->setParam('snippet', $documentOnSuccess);
}

if (is_null($documentOnSuccess)) {
$documentOnSuccess = $formObject->getSuccessRedirect();
}

if ($documentOnSuccess instanceof Page) {
return new RedirectResponse($documentOnSuccess->getFullPath());
} elseif ($documentOnSuccess instanceof Snippet) {
$info->setParam('snippet', $documentOnSuccess);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"key";"cs";"de";"en";"es";"fa";"fr";"hu";"it";"ja";"nl";"pl";"pt";"ru";"sk";"sv";"th";"tr";"uk";"pt_BR";"sv_FI";"zh_Hans"
"key";"cs";"de";"en";"es";"fa";"fr";"hu";"it";"ja";"nl";"pl";"pt";"ru";"sk";"sv";"th";"tr";"uk";"pt_BR";"sv_FI";"zh_Hans"
"pimcore_simple_forms.be.accept";"";"Datentypen";"Accept";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";""
"pimcore_simple_forms.be.accept.tooltip";"";"Mögliche Datentypen";"Restrict types via HTML5 accept attribute";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";""
"pimcore_simple_forms.be.autocomplete";"";"Autocomplete";"Autocomplete";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";""
Expand Down Expand Up @@ -49,3 +49,4 @@
"pimcore_simple_forms.be.help";"";"Beschriftung";"Label";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";""
"pimcore_simple_forms.be.action";"";"Action";"Action";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";""
"pimcore_simple_forms.be.method";"";"Method";"Method";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";""
"pimcore_simple_forms.be.selected_form_object";"";"Form-Objekt";"Form DataObject";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";""
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"key";"de";"en"
"Submit";"Absenden";"Submit"
"pimcore_simple_forms.be.selected_form_object";"Form-Objekt";"Form DataObject"
"pimcore_simple_forms.fe.selected_form_object";"Bitte einen Form-Objekt zuweisen";"Please select a DataObject"
"pimcore_simple_forms.fe.selected_form_object";"Bitte einen Form-Objekt zuweisen";"Please select a DataObject"
"pimcore_simple_forms.fe.selected_form_success_redirection";"Weiterleitung überschreiben";"Override Success Redirection"

0 comments on commit 48cbca4

Please sign in to comment.