-
Notifications
You must be signed in to change notification settings - Fork 196
How to setup form view helpers #217
How to setup form view helpers #217
Conversation
@RalfEggert — I've converted this issue into a pull request containing updated (cookbook) documentation on how to use the helper configuration files from components to configure the The documentation is based on zendframework/zend-expressive-skeleton#34, which updates the base zend-view configuration to ensure the |
If you have any doubts using with Aura.Di, I am happy to help. Thank you. |
@harikt Is there a way to extend/decorate a service in Aura.Di? If so, can you provide a gist? I can then update this PR to incorporate that information. |
Hm. that is a tough question that I don't know or I am not getting the question. May be we should ping @pmjones . |
I've also added a section detailing a simpler method: replacing the |
One thing probably I can tell you, If you have registered a service $di->set('Zend\View\HelperPluginManager', $di->lazyNew('Zend\View\HelperPluginManager'));
// middleware instantiation
$di->params['FormHelpersMiddleware']['helpers'] = $di->lazyGet('Zend\View\HelperPluginManager'); In your middleware you can inject the use Zend\Form\View\HelperConfig;
class FormHelpersMiddleware
{
private $helpers;
public function __construct(HelperPluginManager $helpers)
{
$this->helpers = $helpers;
}
public function __invoke($request, $response, callable $next)
{
$config = new HelperConfig();
$config->configureServiceManager($this->helpers);
return $next($request, $response);
}
} Is this something you were looking for ? |
The simplest, most portable way is to just replace the factory with your own.
345d559
to
afedeec
Compare
I noticed your commit little late ie why the first reply. Seems you already found some other way. |
@harikt I actually demonstrate the middleware-based solution already, and added another solution today that demonstrates simply replacing the |
yes, I copied the middleware code from your commit. The only thing I added was the aura/di config.
great! . |
It's unneeded; the |
@weierophinney I will test it while working on the Album tutorial code and give some feedback here when finished... |
@weierophinney tested the first solution with "Replacing the HelperPluginManager factory" and it worked like a charm 👍 nice |
I have setup my
Zend\Expressive
application and really like the lightweight approach. But currently I am struggling to set up form view helpers to output a form in a view template. One issue I tracked down is due to the fact, thatZend\Form
is not fully refactored to use the latestZend\ServiceManager
changes. But I am not sure if that is all to fix this.I found some posts. The first is about integrating with Aura.DI:
http://harikt.com/blog/2015/11/13/integrating-zend-form-in-zend-expressive-and-view/
And the second with
Zend\ServiceManager
(which I could not get to run due to the current incompatibilities mentioned above):http://www.masterzendframework.com/zend-expressive-enable-form-view-helpers/
It would be nice if the usage of form view helpers could be supported to help beginners adapt
Zend\Expressive
. I don't care if this can be done with an additional package, or within the Cookbook. At least the problem should be addressed to help the beginners.What needs to be done to use the good old form view helpers within my
Zend\Expressive
project?