I am trying to save a hasOne relation, but i cannot seem to get it working, the cookbook isn’t helpful either with different explanations on what should be done.
i have a Users table:
id char(36) username varchar255
and a Zones table:
id char(36) user_id char(36)
$this->belongsTo('Users', [ 'foreignKey' => 'user_id', 'joinType' => 'INNER' ]);
$this->hasOne('Zones', [ 'foreignKey' => 'user_id' ]);
On editing a user I would like to get a dropdown with Zones in the Zones table. If selecting a Zone and saving the user_id should be filled in at the Zones table.
Is a zone has a user_id it can no longer be used for other users.
I baked a edit controller and view. What should i do to get this working, if at all possible?