Skip to content

Instantly share code, notes, and snippets.

@hellomedia
hellomedia / link_with_POST.php
Created January 23, 2015 14:35
Symfony2 link with POST Controller
namespace AppBundle\Controller;
use AppBundle\Entity\Foo;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
@hellomedia
hellomedia / link_with_POST.html.twig
Last active August 29, 2015 14:14
Symfony2 link with POST Twig
<html>
<a href="{{ path('secure_route', {'id': foo.id }) }}" data-method="POST" data-csrf="{{ csrf_token('foo') }}">submit</a>
<script>
/**
* POST/PUT/DELETE with link
* create a form with given HTTP method
* Add CSRF token
* Append and submit