aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2019-02-04 10:31:20 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2019-02-04 12:30:59 +0000
commit120b57d121f426ac54d390e649518b737748d58c (patch)
tree49160480f0de3fb3bf9c80df83ab78cd252e0301
parent5e946a60ac98c984ca21ba3203ccb03be17d9a39 (diff)
Allow Open311 codes starting with ‘_’ to function.
Template Toolkit treats keys starting with ‘_’ as private and does not expose them. It is possible for an Open311 server to return fields starting with an underscore, and we want to use those in the template.
-rw-r--r--CHANGELOG.md1
-rw-r--r--perllib/FixMyStreet/App/Controller/Report.pm2
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm4
-rw-r--r--templates/web/base/report/new/category_extras_fields.html11
4 files changed, 10 insertions, 8 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d176fbbd7..2d295fd1f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,7 @@
- Remove any use of `my $x if $foo`. #2377
- Fix saving of inspect form data offline.
- Add CSRF and time to contact form.
+ - Fix issue with Open311 codes starting with ‘_’.
* v2.5 (21st December 2018)
- Front end improvements:
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm
index a7a3328dc..12f6ec1d1 100644
--- a/perllib/FixMyStreet/App/Controller/Report.pm
+++ b/perllib/FixMyStreet/App/Controller/Report.pm
@@ -373,7 +373,7 @@ sub inspect : Private {
my $permissions = $c->stash->{_permissions};
$c->forward('/admin/categories_for_point');
- $c->stash->{report_meta} = { map { $_->{name} => $_ } @{ $c->stash->{problem}->get_extra_fields() } };
+ $c->stash->{report_meta} = { map { 'x' . $_->{name} => $_ } @{ $c->stash->{problem}->get_extra_fields() } };
if ($c->cobrand->can('council_area_id')) {
my $priorities_by_category = FixMyStreet::App->model('DB::ResponsePriority')->by_categories($c->cobrand->council_area_id, @{$c->stash->{contacts}});
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index e6c4fe50d..2de1d8551 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -1078,7 +1078,7 @@ sub set_report_extras : Private {
foreach my $field ( @$metas ) {
if ( lc( $field->{required} ) eq 'true' && !$c->cobrand->category_extra_hidden($field)) {
unless ( $c->get_param($param_prefix . $field->{code}) ) {
- $c->stash->{field_errors}->{ $field->{code} } = _('This information is required');
+ $c->stash->{field_errors}->{ 'x' . $field->{code} } = _('This information is required');
}
}
push @extra, {
@@ -1093,7 +1093,7 @@ sub set_report_extras : Private {
if ( scalar @$contacts );
if ( @extra ) {
- $c->stash->{report_meta} = { map { $_->{name} => $_ } @extra };
+ $c->stash->{report_meta} = { map { 'x' . $_->{name} => $_ } @extra };
$c->stash->{report}->set_extra_fields( @extra );
}
}
diff --git a/templates/web/base/report/new/category_extras_fields.html b/templates/web/base/report/new/category_extras_fields.html
index a634f8f72..df6129672 100644
--- a/templates/web/base/report/new/category_extras_fields.html
+++ b/templates/web/base/report/new/category_extras_fields.html
@@ -1,27 +1,28 @@
[%- FOR meta IN metas %]
[%- meta_name = meta.code -%]
+ [%- x_meta_name = 'x' _ meta.code # For report_meta and field_erros lookup, as TT hides codes starting "_" -%]
[% IF c.cobrand.category_extra_hidden(meta) AND NOT show_hidden %]
- <input type="hidden" value="[% report_meta.$meta_name.value | html %]" name="[% cat_prefix %][% meta_name %]" id="[% cat_prefix %]form_[% meta_name %]">
+ <input type="hidden" value="[% report_meta.$x_meta_name.value | html %]" name="[% cat_prefix %][% meta_name %]" id="[% cat_prefix %]form_[% meta_name %]">
[% ELSIF meta.variable != 'false' || NOT hide_notices %]
<label for="[% cat_prefix %]form_[% meta_name %]">[% meta.description %]</label>
[% TRY %][% INCLUDE 'report/new/_category_extra_field_notice.html' %][% CATCH file %][% END %]
- [% IF field_errors.$meta_name %]
- <p class='form-error'>[% field_errors.$meta_name %]</p>
+ [% IF field_errors.$x_meta_name %]
+ <p class='form-error'>[% field_errors.$x_meta_name %]</p>
[% END -%]
[% IF meta.variable != 'false' %]
[% IF meta.exists('values') %]
<select class="form-control" name="[% cat_prefix %][% meta_name %]" id="[% cat_prefix %]form_[% meta_name %]"[% meta.required == 'true' ? ' required' : '' %]>
<option value="">[% loc('-- Pick an option --') %]</option>
[% FOR option IN meta.values %]
- <option value="[% option.key %]"[% IF option.key == report_meta.$meta_name.value %] selected[% END %]>[% option.name %]</option>
+ <option value="[% option.key %]"[% IF option.key == report_meta.$x_meta_name.value %] selected[% END %]>[% option.name %]</option>
[% END %]
</select>
[% ELSE %]
- <input class="form-control" type="[% meta.fieldtype OR 'text' %]" value="[% report_meta.$meta_name.value | html %]" name="[% cat_prefix %][% meta_name %]" id="[% cat_prefix %]form_[% meta_name %]"[% meta.required == 'true' ? ' required' : '' %]>
+ <input class="form-control" type="[% meta.fieldtype OR 'text' %]" value="[% report_meta.$x_meta_name.value | html %]" name="[% cat_prefix %][% meta_name %]" id="[% cat_prefix %]form_[% meta_name %]"[% meta.required == 'true' ? ' required' : '' %]>
[% END %]
[% END %]