Skip to content

[router] Does not take additional GET parameter in account if it has a default value. #18035

@Alsatian67

Description

@Alsatian67

In a Controller, I have two actions :

    /**
     * @Route("/search", name="search_with_default", defaults={"p"=1})
     */
    public function searchWithDefaultAction(Request $request)
    {
        return $this->render('default/index.html.twig');
    }

    /**
     * @Route("/search", name="search_without_default")
     */
    public function searchWithoutDefaultAction(Request $request)
    {
        return $this->render('default/index.html.twig');
    }

In twig, I generate routes to these actions with an additional GET parameter 'p' :

    {{ path('search_with_default',{'p':2}) }}<br/>
    {{ path('search_without_default',{'p':2}) }}

Result :

/app_dev.php/search
/app_dev.php/search?p=2 

The first one, totally ignore the value assigned on 'p'.

Bug reproduced here :

https://github.com/Alsatian67/symfony-standard

(index page shows the two paths)

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