Hello all,
I've submitted PR #1884 to ZF2, which provides a plugin to assist with the Post/Redirect/Get pattern (
http://en.wikipedia.org/wiki/Post/Redirect/Get). TL;DR: when a user POSTs a form, they should be redirected to a GET to maintain back button support.
The plugin accepts a string as a parameter, which can be a named route or a URL (either relative or absolute, though I highly recommend absolute). Its return type falls under three basic cases:
- initial GET (i.e. the user has loaded your form for the first time) - plugin will return false
- POST (i.e. the user has submitted your form) - plugin will return a Zend\Http\Response object that you can, in turn, return from your controller's action
- derived GET (i.e. the user has submitted your form and has been redirected) - plugin will return an array containing the POST params of the previous request
The PR has yet to be merged, so I'd be very grateful for any comments or suggestions. You can review the diff here: https://github.com/zendframework/zf2/pull/1884/files
---
Ben Youngblood