SonataAdminBundle json_array field giving INVALID

2019-08-16 02:40发布

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?

0条回答
登录 后发表回答