SonataAdminBundle json_array field giving INVALID MODE / String conversion error

你。 提交于 2020-01-06 04:33:27

问题


I am using doctrine/dbal v2.9.2 and sonata-project/admin-bundle 3.47.0

I have a simple database table with a data field of jsonb type.

/**
 * @ORM\Column(type="json",nullable=true,options={"jsonb"=true})
 */
private $data;

When I try to edit this field with SonataAdminBundle I get errors.

If I import use Sonata\Form\Type\CollectionType; then I get error: INVALID MODE : sb14b159283_data - type : sonata_type_collection - mapping : json

If I import use Sonata\AdminBundle\Form\Type\CollectionType; then I receive error: An exception has been thrown during the rendering of a template ("Notice: Array to string conversion").

The field holds a single array for now. For example {"image": ["c87d2cb7a1818811d90492bdc5f20e973ee6c1cd.jpg"]}

I simply tried to define it as CollectionType::class

protected function configureFormFields(FormMapper $formMapper)
{
    $formMapper
        ->add('id', 'integer')
        ->add('name', 'text')
        ->add('data', CollectionType::class);
    ;
}

What am I missing?

来源:https://stackoverflow.com/questions/56131156/sonataadminbundle-json-array-field-giving-invalid-mode-string-conversion-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!