" tags:
*
*
* use Symfony\Component\Form\Extension\Templating\TemplatingExtension;
*
* $formFactory = Forms::createFormFactoryBuilder()
* ->addExtension(new TemplatingExtension($engine, null, array(
* 'FrameworkBundle:Form',
* )))
* ->getFormFactory();
*
*
* The next example shows how to include the "
" layout:
*
*
* use Symfony\Component\Form\Extension\Templating\TemplatingExtension;
*
* $formFactory = Forms::createFormFactoryBuilder()
* ->addExtension(new TemplatingExtension($engine, null, array(
* 'FrameworkBundle:Form',
* 'FrameworkBundle:FormTable',
* )))
* ->getFormFactory();
*
*
* If you also loaded the CsrfExtension, you should pass the CSRF provider
* to the extension so that you can render CSRF tokens in your templates
* more easily:
*
*
* use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
* use Symfony\Component\Form\Extension\Csrf\CsrfProvider\DefaultCsrfProvider;
* use Symfony\Component\Form\Extension\Templating\TemplatingExtension;
*
*
* $secret = 'V8a5Z97e...';
* $csrfProvider = new DefaultCsrfProvider($secret);
* $formFactory = Forms::createFormFactoryBuilder()
* ->addExtension(new CsrfExtension($csrfProvider))
* ->addExtension(new TemplatingExtension($engine, $csrfProvider, array(
* 'FrameworkBundle:Form',
* )))
* ->getFormFactory();
*
*
* @author Bernhard Schussek
*/
final class Forms
{
/**
* Creates a form factory with the default configuration.
*
* @return FormFactoryInterface The form factory.
*/
public static function createFormFactory()
{
return self::createFormFactoryBuilder()->getFormFactory();
}
/**
* Creates a form factory builder with the default configuration.
*
* @return FormFactoryBuilderInterface The form factory builder.
*/
public static function createFormFactoryBuilder()
{
$builder = new FormFactoryBuilder();
$builder->addExtension(new CoreExtension());
return $builder;
}
/**
* This class cannot be instantiated.
*/
private function __construct()
{
}
}