CakePHP 3.0.0-alpha1 save hasOne

2014-07-07 Thread kalbarsky
Hi, Now that cakephp 3 is in alpha, i'm trying to port an app written with cakephp 2.x. Before the problem, i have to say that the team is doing an amazing job...the new orm, no more array[][][] headache and much more ^^ So i have two model which are: Computers and ComputerConfigs. The

Re: CakePHP 3.0.0-alpha1 save hasOne

2014-07-07 Thread José Lorenzo
For first level associations it is not necessary to add ['associated' = ['ComputerConfigs'] a normal save() should work. I suggest to take a look at your Computer entity file. It should list the field 'computer_config' in the $_accessible array. Otherwise the tampering protection mechanism

Re: CakePHP 3.0.0-alpha1 save hasOne

2014-07-07 Thread kalbarsky
Thank for your answer, and yes it works after checking the $_accessible var. I baked whole project, and by default the association was hasMany and not hasOne. I corrected this just after baking but not $_accessible who stay with computer_config*s* instead of computer_config. Thank's again. Le

Re: CakePHP 3.0.0-alpha1 save hasOne

2014-07-07 Thread José Lorenzo
Glad that it worked :) On Monday, July 7, 2014 2:38:42 PM UTC+2, kalb...@gmail.com wrote: Thank for your answer, and yes it works after checking the $_accessible var. I baked whole project, and by default the association was hasMany and not hasOne. I corrected this just after baking but

Save hasOne

2008-10-08 Thread Günther Theilen
Hi, let's say there are two models: BasicEntry hasOne AdvancedEntry AdvancedEntry belongsTo BasicEntry In the advanced_entries table in the DB there is a field called basic_entry_id In views/basic_entries_edit.ctp there is something like this: $form-input('BasicEntry.foo');

Re: Save hasOne

2008-10-08 Thread grigri
If you use the Security Component then the Form Helper will automatically generate and manage hash fields to make sure that hidden fields are not modified (amongst other things) (I've found it to cause more problems than it solves, however - give it a go). To be honest, I rarely make use of

Re: Save hasOne

2008-10-08 Thread Günther Theilen
OK, I'll have another look at the security component. The last time I tried it, I found the same you did: it caused more problems than it solved. Thanks anyway. grigri: If you use the Security Component then the Form Helper will automatically generate and manage hash fields to make sure

Re: Save hasOne

2008-10-08 Thread grigri
Add a hidden field containing the AdvancedEntry id to the form: echo $form-input('BasicEntry.bacon'); echo $form-input('AdvancedEntry.id'); echo $form-input('AdvancedEntry.eggs'); (The `id` of the BasicEntry is transmitted to the edit action as the 1st parameter, so you don't need to do this

Re: Save hasOne

2008-10-08 Thread Günther Theilen
Yeah, I thought about that. But what happens if a user changes the value of the hidden field AdvancedEntry.id? So I would have to check if the field has the right value. And in that case I could just drop the hidden field. Or am I missing something? Regards Guenther grigri wrote: Add a

Re: Save hasOne

2008-10-08 Thread teknoid
Store the id in the session. On Oct 8, 9:25 am, Günther Theilen [EMAIL PROTECTED] wrote: OK, I'll have another look at the security component. The last time I tried it, I found the same you did: it caused more problems than it solved. Thanks anyway. grigri: If you use the Security