Skip to content

Creating a route with an empty (optional) parameter doesn't work anymore #7316

Closed
@xantos05

Description

@xantos05

Since updating to Symfony 2.2.0 i can't create a route with an empty parameter. This parameter is indicated as optional and worked fine in previous versions of Symfony. Of course i can build in a check but i wonder if this is normal behaviour.

My Route looks like this:
show_products:
path: /showProduct/{size}/{nr}
defaults: { _controller: TestShopBundle:Product:showProduct, nr: 0 }

In Twig:
{{ path('show_product', { 'size': 1, 'nr': entity.nr }) }}

entity.nr sometimes has a null value!

The following error appears:
An exception has been thrown during the rendering of a template ("Parameter "nr" for route "show_product" must match "[^/]++" ("" given) to generate a corresponding URL.") in TestShopBundle:Frontend:index.html.twig at line 270

Probably not a very serious bug but it's not described in the upgrade document -> https://github.com/symfony/symfony/blob/2.2/UPGRADE-2.2.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions