zendframework / zend-view

View component from Zend Framework
BSD 3-Clause "New" or "Revised" License
49 stars 61 forks source link

Viewhelper returns empty string when asking for a route defined as Method with verb 'post' #191

Closed TheDutchCoder closed 5 years ago

TheDutchCoder commented 5 years ago

I have a route defined as follows:

'email-signup' => [
    'type' => \Zend\Router\Http\Method::class,
    'options' => [
        'route' => '/email-signup',
        'verb' => 'post',
        'defaults' => [
            'controller' => \Email\Controller\EmailController::class,
            'action' => 'emailSignup',
        ],
    ],
],

However the URL Viewhelper is not able to echo that route at all:

// Returns nothing
echo $this-url('email-signup');

If I change my route to a Literal, or Segment, it works fine, but not when defined as a Method.

Maybe there's a reason for this, but it's incredibly annoying when building forms (which require and action URL, but the URL itself should only accept posts).

TheDutchCoder commented 5 years ago

Apparently Method doesn't use route names at all. Will find another way.