Sorry for my English, I hope you can understand my request.
I would like to use the MapRequestPayload attribute to create an entity from the POST request data.
I then validate this and then save it.
This works very well so far, but how do you deal with data from a select?
{
"name": "test",
"firstname": "test",
"company_id": 486
}
compay_id is a select in a frontend.
This is of course ignored when assigning, which is ok because it shouldn’t be created, but the relationship should be saved.
My approach would now be the following, but it doesn’t work because the MapEntity attribute refers to the Request Query.
public function add(
#[MapRequestPayload] Person $person,
#[MapEntity(id: 'company_id')] Company $company
): JsonResponse
{
$person->setCompany($company);
}
Do you know a way to do that?