# Shopware 6 OneToMany relation

**URL:** <https://forum.shopware.com/t/shopware-6-onetomany-relation/69868>\
**Category:** General Questions (EN)\
**Tags:** shopping-worlds\
**Created:** [27. September 2020 um 08:31 UTC](https://forum.shopware.com/t/shopware-6-onetomany-relation/69868 "2020-09-27T08:31:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pedramham](https://avatars.discourse-cdn.com/v4/letter/p/ce73a5/32.png) [@pedramham](https://forum.shopware.com/u/pedramham)\
**Post date:** [27. September 2020 um 08:31 UTC](https://forum.shopware.com/t/shopware-6-onetomany-relation/69868/1 "2020-09-27T08:31:22Z")

</div>

I am going to define a OneToMany relation in the Shopware 6 .in my case i am going to have an article linked with many tags. I understand that those situations can be too complex in the Shopware and depends on many things. and it is hard to help. But if introduce to me a tutorial or code example, it will help me

**My ArticleEntity**

```
class ArticleEntity extends Entity
{

    /**
     * @var TagEntity|null
     */
    protected $tag;
    protected $tagId;

    public function getTagId() : ?array { return $this->tagId; }
    public function setTagId(array $value): void { $this->tagId = $value; }

    public function getTag(): ?TagEntity { return $this->tag;}
    public function setTag(TagEntity $value): void { $this->tag = $value; }
.
.
.
}

```

**ArticleDefinition**

```
class ArticleDefinition extends EntityDefinition
{
.
..
 protected function defineFields(): ArticleCollection
    {
..
    new OneToManyAssociationField('tag', TagDefinition::class, 'id'),

}

```

**article-detals.html.twig**

 ![](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/2X/0/05f6fb75bb04c335f8462131fda2af569a05c749.png)

&nbsp;

after submit i get this error

```
{"0":{"code":"FRAMEWORK__WRITE_CONSTRAINT_VIOLATION","status":"400","detail":"This value should be of type string.","template":"This value should be of type string.","meta":{"parameters":[]},"source":{"pointer":"/0/tagId"}}}

```

What is my wrong .I tried to found a solution but can’t found anything .I tried to found to some codes example close to my situation but i don’t succeed.

&nbsp;

&nbsp;

&nbsp;
