I am trying to create a Symfony form (in Silex) by name. Using the configuration below, I find that I need to call $form = $app['form.factory']->createBuilder('address'); , however, FormRegistry cannot find a form of this type.
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormTypeExtensionInterface; class AddressType extends AbstractType implements FormTypeExtensionInterface { public function getName() { return 'address'; } public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('addressee', 'text');
It is then added to the forms registry using the form.type.extensions provider:
$app['form.type.extensions'] = $app->share($app->extend('form.type.extensions', function($extensions) use ($app) { $extensions[] = new AddressType(); return $extensions; }));
Is there anything else I need to do, or another way to create the form this way?
source share