A
A
Alexander2016-02-15 15:49:43
symfony
Alexander, 2016-02-15 15:49:43

How to fix an error when creating a form in Symfony 3?

I am getting an error while creating the form. Expected argument of type "string", "form path" given
500 Internal Server Error - UnexpectedTypeException. Googling hasn't turned up anything yet, maybe someone can help.
A piece of code in the controller:

$form = $this->createForm(new ConferenceType(), $conference, array(
            'action' => $this->generateUrl('mcm_demo_collection_form'),
            'method' => 'POST',
        ));

A piece of code from the form:
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('name', 'text', array(
                'label' => 'Conference Name',
            ))
            ->add('speakers', 'collection', array(
                'type'  => new SpeakerType()
            ))
            ->add('save', 'submit', array(
                'attr'  => array(
                    'class' => 'btn btn-lg btn-success'
                )
            ))
        ;
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2016-02-15
@ghost1k

found the answer:

$form = $this->createForm(ConferenceType::class, $conference, array(
...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question