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
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.