diff options
author | Matthew Somerville <matthew@mysociety.org> | 2016-03-08 17:26:04 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2016-03-09 15:31:40 +0000 |
commit | a5636fc2acd3e03b853f3644fedc054e3eb8b905 (patch) | |
tree | d4e60f0e25c27574045fd069df9904f55dc3a1fb /perllib/FixMyStreet/App/Controller/Report/New.pm | |
parent | b3c925c1b76b93e7c952f1925a959346fae72bef (diff) |
Add cobrand-specific custom reporting fields.
This adds a new cobrand variable, report_form_extras, which contains a
list of extra fields that will be saved in the 'extra' metadata of the
report. Fields may optionally be marked as required.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Report/New.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index a9814e426..6aaa4531f 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -854,12 +854,6 @@ sub process_report : Private { $bodies = join( ',', @{ $c->stash->{bodies_to_list} } ) || -1; $report->bodies_str( $bodies ); - my %extra; - $c->cobrand->process_open311_extras( $c, undef, \%extra ); - if ( %extra ) { - $report->extra( \%extra ); - } - } elsif ( $report->category ) { # FIXME All contacts were fetched in setup_categories_and_bodies, @@ -950,6 +944,15 @@ sub process_report : Private { } + # Get a list of custom form fields we want and store them in extra metadata + foreach my $field ($c->cobrand->report_form_extras) { + my $form_name = $field->{name}; + my $value = $c->get_param($form_name) || ''; + $c->stash->{field_errors}->{$form_name} = _('This information is required') + if $field->{required} && !$value; + $report->set_extra_metadata( $form_name => $value ); + } + # set defaults that make sense $report->state('unconfirmed'); |