0

This is my controller Symfony :

$em = $this->getDoctrine()->getManager();
$advert = $em->getRepository('OCPlatformBundle:Advert')->find($id);
if ($advert == null) {
  throw $this->createNotFoundException("L'annonce d'id ".$id." n'existe pas.");
}
      $em->remove($advert);
      $em->flush();

      $request->getSession()->getFlashBag()->add('notice', 'Annonce bien enregistrée.');

      return $this->redirect($this->generateUrl('oc_platform_view', array('id' => $advert->getId())));
    }


  }

and in twig

{% for advert in adverts %}
        <li>{{ advert.name|e }}</li>
<a href="{{ path('delete_route_name', {'id': advert.id }) }}">Delete</a>
    {% endfor %}

Please help, I dont know how to make angularJs to show modal confirmation for delete action and refresh my view page

2
  • Hi and welcome to stackoverflow. You should start formatting your code properly (indentation etc...) to make it more readable for yourself and others Commented Oct 21, 2015 at 19:41
  • please read the how to ask guide Commented Oct 22, 2015 at 8:30

1 Answer 1

4

You can do it in javascript:

<a href="javascript:void(0)" onclick="if(confirm('Are you sure?')){window.location='{{ path('delete_route_name', {'id': advert.id }) }}';}">delete</a>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.