php - Symfony 2 - included form in all views and handled by one controller -
i using symfony 2 , having little issue embeded form.
the situation :
mybundle/resources/views/portions/footer.html.twig view included in mybundle/resources/views/layout, , of course layout.twig.html extended bundle views. whish means footer.html.twig displayed in pages.
the question / problem :
i want embed newsletter form (one input) in footer.html.twig, handled 1 controller (validate data, database insert, , email send), , afterward, returning same page.
what optimized solution handle ?
thank you.
an easy way of doing (not best way)
is simple define service, twig global, way can have form available, twig, time.
# twig configuration twig: ... globals: myglobaservice: "@acme.newsletter_service" another simple way of doing this, use twig render tag, include entire controller action, wich renders template.
{{ render(controller('acmenewsletterbundle:default:rendernewsletterform', {})) }}
Comments
Post a Comment