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

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -