[ad_1]
I’m using ApiPLatform 3, Axios and EasyAdmin 3. In my form when I choose an institution, all the fields from Address are filled from the choosen institution.
This is how I did ins JS :
selectInstitution.addEventListener('change', () => {
institutionId = selectInstitution.options[selectInstitution.selectedIndex].value;
axios.get(`/api/institutions/${institutionId}`).then(response => {
if (200 === response.status) {
agendaStreet.value = response.data.address ? response.data.address.street : '';
agendaComplementStreet.value = response.data.address ? response.data.address.complement : '';
agendaZipcode.value = response.data.address ? response.data.address.city.zipCode : '';
agendaCity.value = response.data.address ? response.data.address.city.name : '';
}
});
});
Everything work in front but when I submit I’ve got this error :
An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1048 Column ‘institution_address’ cannot be null.
And if I dump after the submit I can see my Entity Address to null. I don’t figure out why symfony does not set the value.
Any idea ?
[ad_2]