Routing post data in ZF2
I have tried to set up a routing in zf2 where all post data of the route /connection/add is routing to a separate method using this yaml configurations:
router:
routes:
home:
type: literal
options:
route: '/'
defaults:
controller: Admin\Dashboard
action: index
connection:
type: literal
options:
route: '/connection'
defaults:
controller: Admin\Connection
action: list
may_terminate: true
child_routes:
add:
type: literal
options:
route: '/add'
defaults:
action: add
may_terminate: true
child_routes:
post:
type: method
options:
verb: post
defaults:
action: test
Everything in the above example works just fine, except the deepest child post that is using the type of Zend\Mvc\Router\Http\Method
Expected output:
When one is submitting post data to the rout /connection/add, that person will be routed to the test action.
Actual output:
The last child in the above routing is ignored and the add action is still invoked upon dispatching post data sent from a form.
Question:
- What am I missing?
- Is there a way to have this kind of routing in my application?
- If so, how could the configuration look?