Symfony twig help with URL change

Hello. In Symfony I am using a base template from which I am building the main layout for my other twig files. Using the base template, at the moment I have this admin.html.twig fire that extends the base template and overwrites some of the blocks defined in the base template.
My problem is with the block addRecord which needs to redirect to a specific URL path that would match a routing for a method in one of my controllers. Clicking this changes the URL to /login instead of /admin/add thus calling the FOSUserBundle login. Can someone help? Thanks

Here is my code that should change the URL:

{% extends 'base.html.twig' %}
{% block admin %}<a class="navbar-brand" href="/admin">Admin Home</a>{% endblock admin %}
{% block addRecord %} <a class="navbar-brand" href="/admin/add">Add Record</a> {% endblock addRecord %}

Routing from Symfony:

Controller function:

/**
     * @Route("/admin/add")
     *
     */
    public function adminAddRecordAction(Request $request){}

I suspect you have a firewall issue which blocks admin routes unless a user is logged in. Hence the security system redirect. Read carefully: http://symfony.com/doc/current/security.html

And a bit off topic but your should name your routes and use the twig path function to generate the actual url. http://symfony.com/doc/current/templating.html#linking-to-pages It will save you headaches later on.

Thanks. Yes that was the problem in security.yml. Starting to name my routes now and use the path. Thanks

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.