symfony2表单错误

Jus*_*tin 3 symfony-forms symfony

The form's view data is expected to be of type scalar, array or an instance of \ArrayAccess, 
but is an instance of class Ecs\CrmBundle\Entity\Customer. 
Run Code Online (Sandbox Code Playgroud)

是我在浏览器中收到的错误..

表格代码:

<?php

namespace Ecs\CrmBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;

class CustomerDefaultConfigType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('name')
            ->add('customerStatus')
            ->add('tags', null, array('multiple' => true, 'property' => 'tag_name'))
        ;
    }

    public function getName()
    {
        return 'ecs_crmbundle_customerdefaultconfigtype';
    }
}
Run Code Online (Sandbox Code Playgroud)

和控制器动作:

<?php

namespace Ecs\CrmBundle\Controller;

use Ecs\CrmBundle\Entity\CustomerDefaultConfig;
use Ecs\CrmBundle\Form\CustomerDefaultConfigType;
    public function newAction()
        {
            $entity = new CustomerDefaultConfig();
            $form   = $this->createForm(new CustomerDefaultConfigType(), $entity);

            return $this->render('EcsCrmBundle:CustomerDefaultConfig:new.html.twig', array(
                'entity' => $entity,
                'form'   => $form->createView()
            ));
        }
Run Code Online (Sandbox Code Playgroud)

这是使用symfony2.1与作曲家...有关如何使这个工作的任何想法?

小智 6

自上次表单重构以来,您必须在类型data_classsetDefaultOptions方法中指定.

看到这里(搜索data_class).

编辑:正确的链接