Rob Allen has a new post today showing how to integrate Zend Framework 2 forms into a Slim framework based application. He started the topic in a previous post and continues, this time using the Twig templating framework to handle the rendering.
The ZF2 view helpers, formRow and formElement now look like Twig functions, however we don't want to have to rewrite all our ZF2 view helpers into Twig. Fortunately, Twig supports the concept of a undefined function callback is called whenever Twig encounters a function that it doesn't know how to call. We can use this to proxy through to the ZendView system and get it to render the ZF2 view helpers.
He shows how to use this callback functionality and a custom view layer with the Slim-Views component to render the output. He includes a simple Slim example, setting up the custom View class as a parser extension and how to register the callback to invoke Twig.
Link: http://akrabat.com/zend-framework-2/using-zf2-forms-with-twig/
没有评论:
发表评论