Hello,
I have built a form base on fieldset wich contains select Element. I created a factory for the fieldset to populate the select with database entries and everything is ok.
But in my controller I get this error when I call myform->isvalid(). Here is the error message
File:
C:\wamp\www\school-online\vendor\laminas\laminas-validator\src\AbstractValidator.php:395
Message:
Argument 1 passed to Laminas\Validator\AbstractValidator::setTranslator() must be an instance of Laminas\Validator\Translator\TranslatorInterface or null, instance of Laminas\I18n\Translator\Translator given, called in C:\wamp\www\school-online\vendor\laminas\laminas-validator\src\ValidatorPluginManager.php on line 580
I need to precise that I have not setted yet the getInputFilter function and haven’t yet setted validator.
Here is my controller code :
<?php
declare(strict_types=1);
namespace Admin\Controller;
use Laminas\View\Model\ViewModel;
use Commun\Controller\NslabsAbstractController;
use Commun\Form\Admin\ClasseForm;
use Commun\Model\Entity\RefClasse;
use Laminas\Hydrator\ArraySerializableHydrator;
class AdministrationFonctionnelleController extends NslabsAbstractController
{
//private $SM;
public function listeDesClassesAction()
{
$post=$this->post;
$mapperRefClasse = $this->SM->get('TREFCLASSE');
$classeForm = $this->formManager->get(ClasseForm::class);
$classeForm->get('enregistrer')->setValue('Enregistrer');
if(!$post){
return new ViewModel(['form' => $classeForm]);
}
$refClasse = new RefClasse();
$hydrator = new ArraySerializableHydrator();
$classeForm->bind($refClasse);
$classeForm->setData($post);
if(!$classeForm->isValid()){
return new ViewModel(['form' => $classeForm]);
}
$data = $hydrator->extract($refClasse);
$additionnalData = [
'idRefUtilisateurCreation' => $this->user->getIdRefUtilisateur(),
];
$mapperRefClasse->insert($data,$additionnalData);
$this->FLASH()->showMessage($this->TRANSLATOR()->translate('enregistrement-succes'));
return $this->redirect()->toRoute('admin-fonctionnelle', ['action' => 'liste-des-classes']);
}
}