zend framework - Unable to use custom validators in ZF2 when creating form using factory -


was wondering if has come across problem previously. using preconfigured form spec create form using zend\form\factory, injecting formelementmanager factory can find custom elements etc.

my question is:

even tho custom validators registered form, not trigger isvalid() method. there need isvalid() triggered creating form factory.

my source looks following:

$spec = [     'hydrator' => '...',     'fieldset' => [         ...,         ...,         ...,     ],     'input_filter' => [         ...,         ....         ....,         //contains custom validator in here     ], ];    $factory = new factory(); $factory->setformelementmanager($formelementmanager); $form = $factory->createform($spec); 

but when trigger:

$form->isvalid() 

it doesn't isvalid call in custom validator.

the input filter factory, zend\inputfilter\factory, dependency of form factory. factory used form factory create inputs should filtered , validated.

in order create new inputs, , attach custom filters , validators, input factory uses zend\inputfilter\inputfilterpluginmanager, inside also seeds 2 other plugin managers, filtermanager , validatormanager.

the zend\validator\validatorpluginmanager plugin manager create custom validator.

so updating code , manually setting dependency allow custom validators found via zend\inputfilter\factory.

$formelementmanager = $servicemanager->get('formelementmanager'); $inputfiltermanager = $servicemanager->get('inputfiltermanager');  $inputfilterfactory = new zend\inputfilter\factory(); $inputfilterfactory->setinputfiltermanager($inputfiltermanager);  $formfactory = new \zend\form\factory();  $formfactory->setformelementmanager($formelementmanager); $formfactory->setinputfilterfactory($inputfilterfactory);  $form = $formfactory->createform($spec); 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -