Quantcast
Channel: Active questions tagged symfony4 - Stack Overflow
Viewing all articles
Browse latest Browse all 3925

Symfony 4: Remove methode is not working with js redirectory

$
0
0

when i use this code

<td class="d-flex justify-content-center" onclick="fct()"><a href="{{ path('admin_card_delete', {slug:restaurantData.slug,id:restaurant.id}) }}"><img src="{{ asset('images/products/cancel.png') }}"></a></td>
    </tbody>

i'm redirected on my deleting page and all things are going well, and the selected element is deleted without any issue.

But when i try this

<td class="d-flex justify-content-center" onclick="fct()"><img src="{{ asset('images/products/cancel.png') }}"></td>
<script>
    function fct(){
        if(confirm("are you sure to delete this item ?")===true)
        {
            document.location.href="{{ path('admin_card_delete', {slug:restaurantData.slug,id:restaurant.id}) }}"
        }}
</script>

The redirection also goes well but for some reason remove method is not working, here is the code of my deleting page.

$em->remove($toRemove);
$em->flush();
return $this->redirectToRoute('admin_restaurant_card',[
    'slug' => $slug,
    'id' => $id
]);

Viewing all articles
Browse latest Browse all 3925

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>