Cakephp4 save two tables with belongsTo

Hello.
I didn’t think I would find it so hard to understand cakephp…
It’s been 3 days that I try to add to 2 different tables, without success.
society (belongsTo) with contact(hasOne).

I would like to start from my table society which has a belongsTo, and make my form from society (I would have other tables to join to society later).

I generated my code with cake bake, here are the files that I modified.
Can you help me please ?

Thanks

SocietyTable

ContactTable

SocietyEntity

SocietyController

AddViewSociety

Not sure if this is the source of the problem, but you’re not doing yourself any favours by using non-standard naming. By default, Cake expects your table names to be plural, e.g. contacts and societies, and the key relating them to then be like contact_id. With that structure, bake does a better job of building the default code for you.

What does your $society object look like after you do the patch?

I tried to recreate a database with cakephp standards but the problem is the same: the foreign key is required. However in all the tutorials I have seen, I do not see anyone having this problem. Do you know how I could solve it please?
Thanks so much.

This is indicating that there’s an error on re_id_contact, that will prevent it from trying to save anything. What does the validation for that field look like?

Indeed it was the default validators, I did not think to look there … Thank you so much !