It would be cool if we could use Symfony's forms component with Grav, in order to create more flexible forms.
Right now, I'm just trying to get it to work in a theme, but in the future there will be a standalone 'advanced forms' plugin.
So Far
composer require symfony/form
In the theme's main file
require_once __DIR__ . '/vendor/autoload.php';
I'm following the examples in the Symfony Book: https://symfony.com/doc/master/book/forms.html
Importing stuff
use Symfony\Component\Form\Forms;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
This runs when the onTwigSiteVariables event fires:
$formFactory = Forms::createFormFactory();
$form = $formFactory->createBuilder()
->add('task', TextType::class)
->add('dueDate', DateType::class)
->add('save', SubmitType::class, array('label' => 'Create Task'))
->getForm();
And a form object actually gets created. Hooray!
The Question
How do I actually render the form using:
{{ form_start(form) }}
{{ form_widget(form) }}
{{ form_end(form) }}
...in one of the theme's template files?