PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, February 15, 2022

[FIXED] Symfony automatically urlencodes routes

 February 15, 2022     php, symfony, symfony5, urlencode     No comments   

Issue

I am using twig to call a route

<a href="{{ path('organisation_feedback', {'id': org.id, 'slug': org.name}) }}">Feedback for organization</a>

I want this path to call my anchor on my organisation-detail page so it jumps right to it

<section id="feedback">
    <div class="row">
        <div class="col-md-6 col-sm-6 col-12">
        <h1>Feedback for organization</h1>

            {{ form (form_organizationFeedback)}} 
        </div>
    </div>
</section>

My route is defined like this

organisation_feedback:
    path: /organisation/{id}/{slug}#feedback
    controller: App\Controller\InsembelController::organisation_detail

Unfortunately what seems to be happening is that symfony routes automatically get urlencoded so the link I am getting in my browser looks like this:

http://symfony.localhost/organization/20/exampleorganization%23feedback

How can I stop symfony from encoding my route so it actually redirects to #feedback and not %23feedback


Solution

In twig fragment should work

<a href="{{ path('organisation_feedback', {'id': org.id, 'slug': org.name, '_fragment' : 'feedback' }) }}">Feedback for organization</a>



Answered By - Bart
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing