Open s-fog opened 1 year ago
I'm also having the same issue.
#[ORM\Entity]
class Prize
{
#[ORM\ManyToOne(targetEntity: Pot::class, inversedBy: 'prizes')]
private Pot $pot;
}
#[ORM\Entity]
class Pot
{
#[ORM\OneToMany(targetEntity: Prize::class, mappedBy: 'pot')]
private Collection $prizes;
}
Using the swagger docs I've manually created some Pots
and then created some Prizes
linked to the Pots
via the IRI
{
"@context": "/contexts/Pot",
"@id": "/pots",
"@type": "hydra:Collection",
"hydra:totalItems": 2,
"hydra:member": [
{
"@id": "/pots/018c5371-d342-7488-bb5a-cfbe322370c7",
"@type": "Pot",
"id": "018c5371-d342-7488-bb5a-cfbe322370c7",
"name": "Pot 1",
"prizes": [
"/prizes/018c5373-d49f-79db-b941-7e63c07ddcfe"
]
},
{
"@id": "/pots/018c537c-9f52-7d8e-bfdd-9cd5b1bd0095",
"@type": "Pot",
"id": "018c537c-9f52-7d8e-bfdd-9cd5b1bd0095",
"name": "Pot 2",
"prizes": []
}
]
}
{
"@context": "/contexts/Prize",
"@id": "/prizes",
"@type": "hydra:Collection",
"hydra:totalItems": 2,
"hydra:member": [
{
"@id": "/prizes/018c476e-6474-7097-8be9-fe9d04ba448b",
"@type": "Prize",
"id": "018c476e-6474-7097-8be9-fe9d04ba448b",
"name": "Test Prize 1"
},
{
"@id": "/prizes/018c5373-d49f-79db-b941-7e63c07ddcfe",
"@type": "Prize",
"id": "018c5373-d49f-79db-b941-7e63c07ddcfe",
"name": "Prize 1",
"pot": "/pots/018c5371-d342-7488-bb5a-cfbe322370c7"
}
]
}
However if I go into the admin and go to edit Prize 1
it's allowing me to select multiple pots.
If I just change the name of the Prize then the PUT request to the API is correct.
{
"@context": "/contexts/Prize",
"@id": "/prizes/018c5373-d49f-79db-b941-7e63c07ddcfe",
"@type": "Prize",
"id": "/prizes/018c5373-d49f-79db-b941-7e63c07ddcfe",
"name": "Prize 13",
"pot": "/pots/018c5371-d342-7488-bb5a-cfbe322370c7",
"originId": "018c5373-d49f-79db-b941-7e63c07ddcfe"
}
If I touch the pots
select it's like it changes to be a multi select because the PUT request changes to an array of pots
{
"@context": "/contexts/Prize",
"@id": "/prizes/018c5373-d49f-79db-b941-7e63c07ddcfe",
"@type": "Prize",
"id": "/prizes/018c5373-d49f-79db-b941-7e63c07ddcfe",
"name": "Prize 13",
"pot": [
"/pots/018c5371-d342-7488-bb5a-cfbe322370c7"
],
"originId": "018c5373-d49f-79db-b941-7e63c07ddcfe"
}
I have the same problem for all ManyToOne relations. There shall be SELECT to pick one relation. There is an interface to assign multiple values.
PHP: 8.2 Symfony: ^6 Api platform: ^3.2 Admin api platform: ^3.4.4
I created entity ProposalType.php
And another entity ProposalParam.php
This is pretty simple ManyToOne relation. Generated by make:entity. I'm dont modified this. Wanted that ProposalParam entity has ProposalType entity by relation, it is simple.
I can create ProposalType via api platform with POST request to /api/proposal_types. And it is successfull. Then i can set this ProposalType in ProposalParam via POST request to /api/proposal_types. And it is successfull. Records are inside database and set up like needed.
When i go to admin panel and send request to create ProposalParam i can set ProposalType.
But request sends as array
And error occured Nested documents for attribute \"proposalType\" are not allowed. Use IRIs instead. And this is expected, we send array, but api wants IRI.
App.js in admin pretty standart, do not modify something
Main goal is why system generate select where i need to specify array of ProposalTypes, instead of one ProposalType. Can someone help with it?