Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Routing] Exception/default value required when navigating to route with a optional parameter with "!" character  #47583

Copy link
Copy link
Closed
@MichaelBelgium

Description

@MichaelBelgium
Issue body actions

Symfony version(s) affected

5.4.8

Description

This is odd and I'm sure this is not the way to go.

When navigating to a route with an optional parameter that has the "!" character (which means the default value will always be included in the generate function) you're required to pass that default parameter when navigating to it.

Which means the optional parameter doesn't have any purpose. As you're required to type it or it throws a ResourceNotFoundException

How to reproduce

Using the example from the announcement blogpost

  1. Define the route
/**
 * @Route("/blog/{!page}", name="blog_list")
 */
public function list($page = 1)
{
    // ...
}
  1. Go to /blog
  2. Have a ResourceNotFoundException
  3. /blog/1 does work but default parameter loses its purpose

Possible Solution

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.