Skip to content

Commit

Permalink
fix: fix validation on two Reg For Operator form fields (#307)
Browse files Browse the repository at this point in the history
* chore: IDEA

* fix: correct validation to not allow empty strings/values on RegForOp page

* fix: tidy template
  • Loading branch information
fibble authored Sep 10, 2024
1 parent ac10eda commit b003847
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 18 deletions.
33 changes: 20 additions & 13 deletions app/selfserve/module/Olcs/config/module.config.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

use Common\Service\Data as CommonDataService;
use Laminas\Router\Http\Segment;
use Laminas\Router\Http\HttpRouterFactory;
use Olcs\Auth\Adapter\CommandAdapter;
use Olcs\Auth\Adapter\CommandAdapterFactory;
use Olcs\Auth\Adapter\SelfserveCommandAdapter;
Expand All @@ -19,18 +19,25 @@
use Olcs\Controller\Factory\IndexControllerFactory;
use Olcs\Controller\Factory\MyDetailsControllerFactory;
use Olcs\Controller\IndexController;
use Common\Service\Data as CommonDataService;
use Olcs\Controller\Licence\Vehicle\ListVehicleController;
use Olcs\Controller\Lva\Adapters\ApplicationPeopleAdapter;
use Olcs\Controller\Lva\Adapters\LicencePeopleAdapter;
use Olcs\Controller\Lva\Adapters\LicenceTransportManagerAdapter;
use Olcs\Controller\Lva\Adapters\VariationPeopleAdapter;
use Olcs\Controller\Lva\Adapters\VariationTransportManagerAdapter;
use Olcs\Controller\Lva\DirectorChange as LvaDirectorChangeControllers;
use Olcs\Controller\Lva\Factory\Adapter\ApplicationPeopleAdapterFactory;
use Olcs\Controller\Lva\Factory\Adapter\LicencePeopleAdapterFactory;
use Olcs\Controller\Lva\Factory\Adapter\LicenceTransportManagerAdapterFactory;
use Olcs\Controller\Lva\Factory\Adapter\VariationPeopleAdapterFactory;
use Olcs\Controller\Lva\Factory\Adapter\VariationTransportManagerAdapterFactory;
use Olcs\Controller\Lva\Factory\Controller\DirectorChange as LvaDirectorChangeControllerFactories;
use Olcs\Controller\Lva\Factory\Controller\Licence as LvaLicenceControllerFactories;
use Olcs\Controller\Lva\Factory\Controller\TransportManager as LvaTransportManagerControllerFactories;
use Olcs\Controller\Lva\Factory\Controller\Variation as LvaVariationControllerFactories;
use Olcs\Controller\Lva\Licence as LvaLicenceControllers;
use Olcs\Controller\Lva\TransportManager as LvaTransportManagerControllers;
use Olcs\Controller\Lva\Variation as LvaVariationControllers;
use Olcs\Controller\MyDetailsController;
use Olcs\Controller\PromptController;
use Olcs\Controller\Search\SearchController;
Expand All @@ -51,16 +58,6 @@
use Olcs\Service\Processing as ProcessingService;
use Olcs\Service\Qa as QaService;
use Olcs\Session\LicenceVehicleManagement;
use Olcs\Controller\Lva\Application as LvaApplicationControllers;
use Olcs\Controller\Lva\Factory\Controller\Application as LvaApplicationControllerFactories;
use Olcs\Controller\Lva\Licence as LvaLicenceControllers;
use Olcs\Controller\Lva\Factory\Controller\Licence as LvaLicenceControllerFactories;
use Olcs\Controller\Lva\Variation as LvaVariationControllers;
use Olcs\Controller\Lva\Factory\Controller\Variation as LvaVariationControllerFactories;
use Olcs\Controller\Lva\TransportManager as LvaTransportManagerControllers;
use Olcs\Controller\Lva\Factory\Controller\TransportManager as LvaTransportManagerControllerFactories;
use Olcs\Controller\Lva\DirectorChange as LvaDirectorChangeControllers;
use Olcs\Controller\Lva\Factory\Controller\DirectorChange as LvaDirectorChangeControllerFactories;

$sectionConfig = new \Common\Service\Data\SectionConfig();
$configRoutes = $sectionConfig->getAllRoutes();
Expand Down Expand Up @@ -543,10 +540,20 @@
'options' => [
'route' => 'register-consultant-account[/]',
'defaults' => [
'controller' => \Olcs\Controller\ConsultantRegistrationController::class,
'controller' => ConsultantRegistrationController::class,
'action' => 'registerConsultantAccount'
]
]
],
'contact-your-administrator' => [
'type' => 'segment',
'options' => [
'route' => 'contact-your-administrator[/]',
'defaults' => [
'controller' => ConsultantRegistrationController::class,
'action' => 'contactYourAdministrator'
]
]
]
]
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function addAction()
if ($form->isValid()) {
$formData = $form->getData();
if(($formData['fields']['existingOperatorLicence'] ?? null) === 'Y') {
// Add "speak to your adminstrator page
$this->redirect()->toRoute('user-registration/contact-your-administrator');
} elseif (($formData['fields']['existingOperatorLicence'] ?? null) === 'N') {
$this->redirect()->toRoute('user-registration/operator-representation');
}
Expand Down Expand Up @@ -103,6 +103,14 @@ public function operatorRepresentationAction()
]);
}

/**
* @return Response|ViewModel
*/
public function contactYourAdministratorAction()
{
return $this->prepareView('olcs/user-registration/contact-your-administrator');
}


/**
* @return Response|ViewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Olcs\Form\Model\Fieldset;

use Laminas\Form\Annotation as Form;

/**
* @Form\Name("RegisterForOperator")
* @Form\Attributes({"method":"post","label":"operator-registration.form.labe"})
Expand Down Expand Up @@ -72,7 +70,6 @@ class RegisterForOperator
* @Form\Type("Text")
* @Form\Attributes({"class":"medium"})
* @Form\Options({"label":"user-registration.field.organisationName.label", "hint": "user-registration.field.organisation-name.hint"})
* @Form\Validator("Laminas\Validator\NotEmpty", options={"null"})
* @Form\Filter("Laminas\Filter\StringTrim")
*/
public $organisationName = null;
Expand All @@ -88,7 +85,6 @@ class RegisterForOperator
* "category": "org_type",
* "exclude": {"org_t_ir"}
* })
* @Form\Validator("Laminas\Validator\NotEmpty", options={"string"})
*/
public $businessType = null;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
echo $this->partial(
'partials/page-header-simple',
[
'pageTitle' => $this->translate('user-registration.page.contact-your-administrator.title'),

]
);
?>

<div class="row">
<div class="two-thirds">
<div class="article">
<p>
<?php echo $this->translate('user-registration.page.contact-your-administrator.content'); ?>
</p>
<p><a href="<?php echo $this->url('auth/login/GET'); ?>" class="govuk-button" ><?php echo $this->translate('back-to-login'); ?></a>
</p>
</div>
</div>
</div>

0 comments on commit b003847

Please sign in to comment.