0

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

  • Can you add some more details? Whole error message for example ;) I'm working with Propel 1.x but syntax seems to be the same and my code is similar to yours. – zelazowy Dec 09 '16 at 07:50
  • It seems the Class Propel\Bundle\PropelBundle\Form\ChoiceList\ModelChoiceList extends Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList which has been removed in favor of Symfony\Component\Form\ChoiceList\ArrayChoiceList in Symfony3. So I manually include this use Propel\Bundle\PropelBundle\Form\Type\ModelType; It seem working fine now... – Hou Lee Schitt Dec 09 '16 at 08:02

1 Answers1

0

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()
));
panche14
  • 651
  • 4
  • 8