Skip to content

Commit

Permalink
include policy we are redirecting to in postcode title
Browse files Browse the repository at this point in the history
If we are redirecting to a policy or policy set then change the title of
the postcode form to mention the policy/set to reassure the user they
are on the right track.
  • Loading branch information
struan committed Apr 13, 2017
1 parent e3b22e1 commit 05eb06f
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion www/docs/postcode/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,26 @@
function postcode_error($error) {
global $PAGE;
$hidden = get_policy_array();
$title = '';
if (count($hidden) > 0 ) {
$policies = new \MySociety\TheyWorkForYou\Policies();

if (isset($hidden['policy_number'])) {
$policies = $policies->getPolicies();
if (isset($policies[$hidden['policy_number']])) {
$title = "Find out how your MP voted on " . $policies[$hidden['policy_number']] . ".";
}
} else if (isset($hidden['policy_set'])) {
$sets = $policies->getSetDescriptions();
if (isset($sets[$hidden['policy_set']])) {
$title = "Find out how your MP voted on " . $sets[$hidden['policy_set']] . ".";
}
}
}
$PAGE->page_start();
$PAGE->stripe_start();
$PAGE->error_message($error);
$PAGE->postcode_form($hidden);
$PAGE->postcode_form($hidden, $title);
$PAGE->stripe_end();
$PAGE->page_end();
exit;
Expand Down

0 comments on commit 05eb06f

Please sign in to comment.