I have a situation where a user is asked to fill out a building questionnaire. A model Buildingcould hasMany Questionnaire, although at least for the moment, be enough to Building hasOne Questionnaire. What bothers me is that the former does not work while the latter does, and I cannot understand why.
The keys follow the convention: buildings.idrefers to the foreign key from questionnaires.building_id. In the script, the hasManyforeign key is simply ignored when trying to insert a record questionnaires:
INSERT INTO `questionnaires` (`deleted`, `modified`, `created`, `id`) VALUES (1, '2011-03-17 10:32:24', '2011-03-17 10:32:24', '4d821b78-7314-4ab4-a532-226f6e891b5e')
No mention building_idat all. As soon as I move Questionnairefrom array hasManyto array hasOne, however, everything works fine.
Any understanding of inner magic would be great. I can’t imagine that I am the first person to encounter this, but I never thought about attacking him before.
Thank.
UPDATE
So, I think I found the answer. In my form, since I really only define one questionnaire (although I could support several), I defined my input as Questionnaire.deletedwhich works fine for hasOne, but not so much for hasMany. For the latter, I have to create an input for Questionnaire.0.deleted. I created forms for countless relationships hasMany, where I was only intended to create one at a time, and I swear that I can’t remember ever done it before. Has this always been a requirement? Maybe I just need to put some heavy things off for a while. Sheesh.