-
Notifications
You must be signed in to change notification settings - Fork 196
Configure FormElementManager #387
Comments
How do you configure I did something similar here: https://github.com/mtymek/blast-input-filter - I configure validator, filter and input filter plugin managers in a similar manner as you do. Take a look - maybe it will give you some hints. |
Like I said, I only have a special Your package looks like a better solution though I am missing hydrators and form elements. The name of the package seems a bit misleading when adding hydrators and form elements. |
So, basically you're missing a factory that does the code you put in My package doesn't have hydrators and form elements because I don't use them (well, I use hydrators but I keep them in main SM...). But I'll be happy to accept PR or even consider changing the package name to something more relevant afterwards. |
@RalfEggert for this i usually use Delegator Factories like <?php
namespace My\Namespace\Form;
use Interop\Container\ContainerInterface;
use Zend\Form\FormElementManager\FormElementManagerV3Polyfill;
use Zend\ServiceManager\Config;
use Zend\ServiceManager\Factory\DelegatorFactoryInterface;
class FormElementManagerDelegatorFactory implements DelegatorFactoryInterface
{
public function __invoke(ContainerInterface $container, $name, callable $callback, array $options = null)
{
$formElementManager = $callback();
$config = $container->has('config') ? $container->get('config') : [];
$config = isset($config['form_elements']) ? $config['form_elements'] : [];
(new Config($config))->configureServiceManager($formElementManager);
return $formElementManager;
}
} and in my ConfigProvider config <?php
return [
'dependencies' => [
'delegators' => [
'HydratorManager' => [
My\Namespace\Hydrator\HydratorManagerDelegatorFactory::class,
],
'InputFilterManager' => [
My\Namespace\InputFilter\InputFilterManagerDelegatorFactory::class,
],
'FormElementManager' => [
My\Namespace\Form\FormElementManagerDelegatorFactory::class,
],
],
],
]; yes, class naming could be improved ;-) |
This repository has been closed and moved to mezzio/mezzio; a new issue has been opened at mezzio/mezzio#16. |
I have a little module that configures the
FormElementManager
like this:This config is loaded by a
ConfigProvider
class and loaded by theConfigManager
in the/config/config.php
file like this:When I want to access the
ProductFormInterface::class
from theFormElementManager
it is not found. I need to these lines to the/config/container.php
file to get this running.What am I doing wrong? I don't think this is a wanted behaviour. In my module I also have some validators, filters, hydrators and input filters as well. Currently, I need to add the configuration manually for every specialized service managers.
The text was updated successfully, but these errors were encountered: