Pls look at the above 5 steps I listed(I edited my reply and added the step 5), it is almost the whole logic for this part, pls help me out!
In fact, I took the above 5 steps and submit the form then I got a error when I use
$inputFilter->add([
'name' => 'customer',
'required' => true,
'filters' => [
['name' => ToInt::class],
],
'validators' => [
[
'name' => RecordExists::class,
'options' => [
'table' => 'main_customers',
'field' => 'id',
'message' => 'custome is not in the database',
'adapter' => 'db.express',
],
],
],
]);
Argument 1 passed to Zend\Validator\Db\AbstractDb::setAdapter() must be an instance of Zend\Db\Adapter\Adapter, string given, called in /opt/www/websites/somedomain.com/vendor/zendframework/zend-validator/src/AbstractValidator.php on line 139
It says that, it need a adatper instance, But I passed a string.
I guess the replacement of the default recordexist validator not happen, I can not overwrite the default RecordExists::class and NoRecordExists::class eighter I put the configuration in global.php or module.config.php, why?
I moved the following configs from module.config.php to global.php
'validators' => [
'factories' => [
Zend\Validator\Db\NoRecordExists::class => Application\Validator\Factory\DbValidatorAbstractFactory::class,
Zend\Validator\Db\RecordExists::class => Application\Validator\Factory\DbValidatorAbstractFactory::class,
],
],