symfony2 表单错误

2024-02-19

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. 

我的浏览器出现错误吗?

表格代码:

<?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';
    }
}

和控制器动作:

<?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()
            ));
        }

这是使用 symfony2.1 和作曲家......关于如何让它工作有什么想法吗?


自上次表单重构以来,您必须指定data_class in the setDefaultOptions你的类型中的方法。

See here https://github.com/symfony/symfony/blob/master/UPGRADE-2.1.md(搜索data_class).

编辑:正确的链接

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

symfony2 表单错误 的相关文章

随机推荐