Reputation: 815
I have entity called Project, it has name
and members
property. Members referencing to User
entity but never mind.
I'm wondering how to handle extra data that passed as json through API.
I would like to pass such as json code:
{
"project": {
"name": "Testowy project",
"members": [
"[email protected]",
"[email protected]"
],
"members_roles": {
"[email protected]": "user",
"[email protected]": "admin"
}
}
}
As you can see, there is member_roles property, but in the entity there is none. I'm not sure if should I set allow_extra_fields as true in form's options and handle it independently – if so, is possible to restrain extra fields only for chosen fields?
I hope I am enough clear.
Upvotes: 0
Views: 900
Reputation: 1879
You can add the field in the form type and set the option mapped
to false
.
You will have access to be submitted value through $form->get('fieldName')->getData()
or via form events.
Upvotes: 1