diff options
author | Matthew Somerville <matthew@mysociety.org> | 2019-08-09 12:36:15 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2019-08-09 12:36:17 +0100 |
commit | c708d6f2d30c5da1b603d227ba013c63c8673457 (patch) | |
tree | b230022738dfd6737e5e73c046438587364c70aa /perllib/FixMyStreet/App/Controller/Report/New.pm | |
parent | 80131ff0362b161c8a3f082e6f81ea9ff1693402 (diff) |
Make sure existing attribute answers set up.
If you come to /report/new with a part-filled report (say you've gone
via an OAuth flow), then the stash needs to get the category from the
report, not a query parameter, and report_meta needs initializing, as
that is what the template uses to fill in existing attribute answers.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Report/New.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index 2246f6aea..120467905 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -104,6 +104,7 @@ sub report_new : Path : Args(0) { $c->forward('setup_report_extra_fields'); $c->forward('generate_map'); $c->forward('check_for_category'); + $c->forward('setup_report_extras'); # deal with the user and report and check both are happy @@ -1073,6 +1074,14 @@ sub contacts_to_bodies : Private { [ map { $_->body } @contacts ]; } +sub setup_report_extras : Private { + my ($self, $c) = @_; + + # report_meta is used by the templates to fill in the extra field values + my $extra = $c->stash->{report}->get_extra_fields; + $c->stash->{report_meta} = { map { 'x' . $_->{name} => $_ } @$extra }; +} + sub set_report_extras : Private { my ($self, $c, $contacts, $param_prefix) = @_; @@ -1458,7 +1467,7 @@ sub generate_map : Private { sub check_for_category : Private { my ( $self, $c ) = @_; - $c->stash->{category} = $c->get_param('category'); + $c->stash->{category} = $c->get_param('category') || $c->stash->{report}->category; return 1; } |