Expected argument of type "string", "Vendor\NameBundle\Form\EntitynameType" given Symfony 3.0 Expected argument of type "string", "Vendor\NameBundle\Form\EntitynameType" given Symfony 3.0 symfony symfony

Expected argument of type "string", "Vendor\NameBundle\Form\EntitynameType" given Symfony 3.0


Forms have changed quite a bit in 3.0. You might be better off sticking with 2.8 for now.

You did not show it but I suspect, based on the error message, that your controller code looks like:

$form = $this->createForm(new ReservernType(), $item);

That is the 2.x way of doing things. For 3.x use:

$form = $this->createForm(ReservernType::class, $item);

http://symfony.com/doc/current/book/forms.html#creating-form-classes


try with:

$builder        ->add('naam', TextType::class);        // If you use PHP 5.3 or 5.4 you must use        // ->add('naam','Symfony\Component\Form\Extension\Core\Type\TextType')

instead of this

$builder    ->add('naam');

And add the use statement:

use Symfony\Component\Form\Extension\Core\Type\TextType;

Motivation: from the upgrade guide:

Type names were deprecated and will be removed in Symfony 3.0. Instead of referencing types by name, you should reference them by their fully-qualified class name (FQCN) instead. With PHP 5.5 or later, you can use the "class" constant for that:

Hope this help


Try like this:

/.../use Symfony\Component\Form\Extension\Core\Type\TextType; /.../class ReserverenType extends AbstractType{    public function buildForm(FormBuilderInterface $builder, array $options)    {           $builder->add('naam', TextType::class);    }}