aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
Diffstat (limited to 'perllib')
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm15
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm11
-rw-r--r--perllib/FixMyStreet/Cobrand/EmptyHomes.pm12
3 files changed, 22 insertions, 16 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');
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index a8e967ba7..b3b830f06 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -754,6 +754,17 @@ If set to an arrayref, will plot those area ID(s) from mapit on all the /around
sub areas_on_around { []; }
+=head2
+
+A list of extra fields we wish to save to the database in the 'extra' column of
+problems based on variables passed in by the form. Return a list of hashrefs
+of values we wish to save, e.g.
+( { name => 'address', required => 1 }, { name => 'passport', required => 0 } )
+
+=cut
+
+sub report_form_extras {}
+
sub process_open311_extras {}
=head 2 pin_colour
diff --git a/perllib/FixMyStreet/Cobrand/EmptyHomes.pm b/perllib/FixMyStreet/Cobrand/EmptyHomes.pm
index 1a18bfa1b..995c39c85 100644
--- a/perllib/FixMyStreet/Cobrand/EmptyHomes.pm
+++ b/perllib/FixMyStreet/Cobrand/EmptyHomes.pm
@@ -132,16 +132,8 @@ sub council_rss_alert_options {
return ( \@options, @reported_to_options ? \@reported_to_options : undef );
}
-sub process_open311_extras {
- my $self = shift;
- my $ctx = shift;
- my $body_id = shift;
- my $extra = shift;
-
- my $value = $ctx->get_param('address') || '';
- $ctx->stash->{field_errors}->{address} = _('This information is required')
- unless $value;
- $extra->{address} = $value;
+sub report_form_extras {
+ ( { name => 'address', required => 1 } )
}
sub front_stats_data {