aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Contact.pm
diff options
context:
space:
mode:
authorZarino Zappia <mail@zarino.co.uk>2017-07-18 16:42:49 +0100
committerZarino Zappia <mail@zarino.co.uk>2017-07-28 14:35:48 +0100
commit405cf67716a5d6ec835973d7093e3a71f9b52879 (patch)
tree3f3a993eb8c34c955b8dc2bd84a066369460ca13 /perllib/FixMyStreet/App/Controller/Contact.pm
parent9d5e44842fdac0d3894ed82885a4079df85ba890 (diff)
Option to redirect to custom URL from Contact form
If a `success_url` parameter is provided along with the contact form fields, the user will be redirected to that URL upon successful form submission. We use it for the first time on the (UK) FixMyStreet Pro marketing page.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Contact.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/Contact.pm22
1 files changed, 20 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Contact.pm b/perllib/FixMyStreet/App/Controller/Contact.pm
index e1eb64ba3..f2c3be47c 100644
--- a/perllib/FixMyStreet/App/Controller/Contact.pm
+++ b/perllib/FixMyStreet/App/Controller/Contact.pm
@@ -54,7 +54,8 @@ sub submit : Path('submit') : Args(0) {
&& $c->forward('determine_contact_type')
&& $c->forward('validate')
&& $c->forward('prepare_params_for_email')
- && $c->forward('send_email');
+ && $c->forward('send_email')
+ && $c->forward('redirect_on_success');
}
=head2 determine_contact_type
@@ -99,7 +100,7 @@ sub determine_contact_type : Private {
=head2 validate
-Validate the form submission parameters. Sets error messages and redirect
+Validate the form submission parameters. Sets error messages and redirect
to index page if errors.
=cut
@@ -262,6 +263,23 @@ sub send_email : Private {
return 1;
}
+=head2 redirect_on_success
+
+Redirect to a custom URL if one was provided
+
+=cut
+
+sub redirect_on_success : Private {
+ my ( $self, $c ) = @_;
+
+ if (my $success_url = $c->get_param('success_url')) {
+ $c->res->redirect($success_url);
+ $c->detach;
+ }
+
+ return 1;
+}
+
=head1 AUTHOR
Struan Donald