Closed bestattendance closed 8 years ago
I can confirm this problem. Downgrading the Symfony components was the only option I could find that worked.
This is not a FormServiceProvider
issue.
It's about one of the few bc break introduced in version 3 of symfony components. You can get this working by changing the deprecated alias form
and text
by FormType::class
and TextType::class
:
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
$this->_form = $this->_app['form.factory']->createBuilder('FormType::class', $this->_map())
->add('firstName', 'TextType::class', [
'constraints' => [new Assert\NotBlank()]
])
->add('lastName', 'TextType::class', [
'constraints' => [new Assert\NotBlank()]
])
->add('email', 'TextType::class', [
'constraints' => [new Assert\Email()]
])
->getForm();
Hello @HeahDude
You forgot to remove quote in your example
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
$this->_form = $this->_app['form.factory']
->createBuilder(FormType::class, $this->_map())
->add(
'firstName',
TextType::class, [
'constraints' => [new Assert\NotBlank()]
]
)
->add(
'lastName',
TextType::class, [
'constraints' => [new Assert\NotBlank()]
]
)
->add(
'email',
EmailType::class, [
'constraints' => [new Assert\Email()]
]
)
->getForm();
see doc
You're right @JonathanRamier, I've mistaken after copy-pasting, thank you !
When trying to build a form I receive this error:
I've registered the FormServiceProvider, TranslationServicerProvider, and ValidatorServiceProvider.
Here is the relevant part of my code:
Here are version numbers of the related components that I'm using:
silex/silex v1.3.5 symfony/security-core v3.0.1 symfony/security-csrf v3.0.1 symfony/translation v3.0.1 symfong/twig-bridge v3.0.1 symfony/validator v3.0.1 symfony/form v3.0.1
Downgrading all symfony components to 2.8.1 solved the problem.