Skip to content

[Admin] Default action doesn't allow to define a URL without also a route #17565

@JeanDavidDaviet

Description

@JeanDavidDaviet

Sylius version affected: 1 and 2

Description
When using the default Grid Action, I must define a route even if I already defined a url. I should be able to not define a route, because the URL is already defined.

Steps to reproduce
Create a button in the grid with the "default" template, and only define the options.link.url .

sylius_grid:
    grids:
        sylius_admin_exchange_rate:
            actions:
                main:
                    custom_url:
                        type: default
                        label: test
                        options:
                            link:
                                url: '/my-custom-url'
                              # route: 'sylius_admin_exchange_rate_index' # needed to work right now

Possible Solution
It seems that the default function is still called even if route is already defined.
It should be able to add a check if URL is defined, then we don't need to have a default route.

{% set path = options.link.url|default('') is not empty ? options.link.url : path(options.link.route, options.link.parameters|default({})) %}

UPDATE :
I just saw the AdminBundle/templates/shared/grid/action/links.html.twig:19 file where the links are handled this way :

{% set path = link.url is defined ? link.url : path(link.route, link.parameters|default([])) %}

Metadata

Metadata

Assignees

No one assigned

    Labels

    AdminAdminBundle related issues and PRs.EnhancementMinor issues and PRs improving the current solutions (optimizations, typo fixes, etc.).

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions