hum2/twig-form

Form Extension for Twig.

0.1.5 2015-08-04 15:12 UTC

This package is not auto-updated.

Last update: 2020-10-16 20:54:40 UTC


README

Build Status Scrutinizer Code Quality

Latest Stable Version Total Downloads Latest Unstable Version License

install

composer require hum2/twig-form

How To Use

index.html.twig

{% form(action=post_url|e, method="POST", enctype="multipart/form-data") %}
<input type="text" name="keyword" />
{% endform %}

index.php

# validate
$factory   = new \Aura\Session\SessionFactory;
$session   = $factory->newInstance($_COOKIE);

$actualToken = $_POST['__csrf_value'];
if (!$session->getCsrfToken()->isValid($actualToken)) {
	// csrf token error
}
// regenerate token(should be onetime token)
$session->getCsrfToken()->regenerateValue();

dependency Package

  • twig/twig
  • aura/session