diff options
Diffstat (limited to 'perllib/FixMyStreet/App/Form/Waste/Request.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Form/Waste/Request.pm | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/Form/Waste/Request.pm b/perllib/FixMyStreet/App/Form/Waste/Request.pm new file mode 100644 index 000000000..e7caaa206 --- /dev/null +++ b/perllib/FixMyStreet/App/Form/Waste/Request.pm @@ -0,0 +1,64 @@ +package FixMyStreet::App::Form::Waste::Request; + +use utf8; +use HTML::FormHandler::Moose; +extends 'FixMyStreet::App::Form::Waste'; + +# First page has dynamic fields, so is set in code + +has_page about_you => ( + fields => ['name', 'email', 'phone', 'continue'], + title => 'About you', + next => 'summary', +); + +with 'FixMyStreet::App::Form::Waste::AboutYou'; + +has_page summary => ( + fields => ['submit'], + title => 'Submit container request', + template => 'waste/summary_request.html', + finished => sub { + return $_[0]->wizard_finished('process_request_data'); + }, + next => 'done', +); + +has_page done => ( + title => 'Container request sent', + template => 'waste/confirmation.html', +); + +has_field category => ( + type => 'Hidden', + default => 'Request new container', +); + +has_field continue => ( + type => 'Submit', + value => 'Continue', + element_attr => { class => 'govuk-button' }, +); + +has_field submit => ( + type => 'Submit', + value => 'Request new containers', + element_attr => { class => 'govuk-button' }, + order => 999, +); + +sub validate { + my $self = shift; + my $any = 0; + + foreach ($self->all_fields) { + $any = 1 if $_->name =~ /^container-/ && ($_->value || $self->saved_data->{$_->name}); + } + $self->add_form_error('Please specify what you need') + unless $any; + + $self->add_form_error('Please specify at least one of phone or email') + unless $self->field('phone')->is_inactive || $self->field('phone')->value || $self->field('email')->value; +} + +1; |