Search code examples
symfonypropel2

Symfony 3.1: Could not load type model


I am trying to create a test application using symfony 3.1 and using Propel 2 and got some error Could not load type "model"

Inside my Form

$builder->add('province', 'model', array(
        'class' => 'Test\MainBundle\Model\Province',
        'query' => ProvinceQuery::create()
            ->orderByName()
    ));

AppKernel

public function registerBundles()
{
    $bundles = [
        new Propel\Bundle\PropelBundle\PropelBundle(),
        ....

Error: Please see the error message


Solution

  • Type names were removed in Symfony3. Instead of referencing types by name, you must reference them by their fully-qualified class name (FQCN) instead. You need to declare your form like this:

    $builder->add('province', ModelType::class, array(
        'class' => 'Test\MainBundle\Model\Province',
        'query' => ProvinceQuery::create()
            ->orderByName()
    ));