-
-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configure FormElementManager #16
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. Originally posted by @mtymek at zendframework/zend-expressive#387 (comment) |
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. Originally posted by @RalfEggert at zendframework/zend-expressive#387 (comment) |
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. Originally posted by @mtymek at zendframework/zend-expressive#387 (comment) |
@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 ;-) Originally posted by @skors at zendframework/zend-expressive#387 (comment) |
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.
Originally posted by @RalfEggert at zendframework/zend-expressive#387
The text was updated successfully, but these errors were encountered: