Example is based using Aura.Di. But the functionality will be same for any containers. First register the service Zend\View\HelperPluginManager, so that we can access the same object.
To register the form helpers, create the object of Zend\Form\View\HelperConfig and pass the Zend\View\HelperPluginManager service.
Example code with Aura.Di version 3 configuration.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 <?php use Aura\Di\ContainerConfig; use Aura\Di\Container; use Zend\Form\View\HelperConfig; class ViewHelper extends ContainerConfig { public function define(Container $di) { $di->set('Zend\View\HelperPluginManager', $di->lazyNew('Zend\View\HelperPluginManager')); } public function modify(Container $di) { $serviceManager = $di->get('Zend\View\HelperPluginManager'); $helper = new HelperConfig(); $helper->configureServiceManager($servicemanager); } } Creating your own zend-view helper # Create your helper class 1 2 3 4 5 6 7 8 9 10 11 12 13 <?php namespace App\View\Helper; use Zend\View\Helper\AbstractHelper; class HasError extends AbstractHelper { // add as many parameters you want to pass from the view public function __invoke() { // some code } } Registering your helper class. First get the Zend\View\HelperPluginManager service.
Rob Allen wrote about Integrating ZF2 forms into Slim. I did write how you can use Aura.Input and Aura.Html to create standalone form for PHP. This time I felt I should write about integrating aura input inside Slim.
Let us install a few dependencies aura/input for building the form and aura/html for the html helpers. You of-course can skip not to use aura/html and build your own helper. I also purposefully left not integrating the powerful Aura.Filter , but you are not limited to integrate any validator you love inside Aura.Input .
Yesterday I wrote about Standalone Forms and Validation. It may need a little bit knowledge on how the Aura.Filter works. But that is a good start if you want to know how you can integrate the pieces of Aura.
Today I think I need to show you the very minimal approach you can take to build the form and validate your form. If you want to use a powerful validation and filtering use something like Aura.Filter or bind your favourite components which does the validation Respect, Symfony2 Validator, valitron and filtering with something like DMS-Filter.
Update : I wrote a very minimal approach here
Recently Aura.Input was tagged Beta1. I would like to show you how you can use Aura.Input, Aura.Filter and Aura.View to create form.
The Aura.Input itself contains a basic filter implementation. As shown in earlier post Aura Turns 2
But in this post let us use the power of Aura.Filter. As Aura.Input doesn’t have a rendering capability you may need to use Aura.View as templating system ( see Using Aura.View ) or use the helper classes provided by Aura.View ( see below Without using Aura.View completely ) or create your own helper classes to render the same from the hints ( see Hints for the view ).