Log message #4123930

# At Username Text
# Mar 12th 2018, 07:37 joddit add 'address' => true to your address_headers entity
# Mar 12th 2018, 07:37 joddit If you're not confident in writing your own models and table, definitely make use of the bake program
# Mar 12th 2018, 07:36 joddit Did you bake these or write them yourslef?
# Mar 12th 2018, 07:36 joddit I see that you don't have addresses in your address_headers entity as well
# Mar 12th 2018, 07:32 bravo-kernel @savant thank you so much for your reviews, could never have spotted those myself :100
# Mar 12th 2018, 07:31 aneh No still not saving plz check this gist https://gist.github.com/anehkumar/d582bac8d595d8dcdf15d8879b00d63f if you find any error in code
# Mar 12th 2018, 07:27 joddit Let me know if that works
# Mar 12th 2018, 07:27 joddit You were only patching it with the association specified but not saving it with the association specified
# Mar 12th 2018, 07:27 joddit Your save call should be $this->AddressHeaders->save($entity, ['associated' => 'Addresses']
# Mar 12th 2018, 07:26 aneh Plz tell me how to fix
# Mar 12th 2018, 07:25 joddit Oh I see it now
# Mar 12th 2018, 07:19 aneh but get same result
# Mar 12th 2018, 07:19 aneh $data = [ 'user_id' => 1, 'company_id' => 9, 'addresses' => [ [ 'user_id' => 1, 'company_id' => 9, 'name' => 'Aneh' ] ] ];
# Mar 12th 2018, 07:19 aneh i also try with this data
# Mar 12th 2018, 07:18 joddit It should have addresses plural and have an index key
# Mar 12th 2018, 07:18 joddit Right so you need to change your data array
# Mar 12th 2018, 07:18 aneh $this->hasMany('Addresses', [ 'foreignKey' => 'address_header_id' ]);
# Mar 12th 2018, 07:18 aneh yes
# Mar 12th 2018, 07:16 joddit Right but you've defined the association as address_headers hasMany addresses right?
# Mar 12th 2018, 07:14 aneh My address entity table protected $_accessible = [ 'user_id' => true, 'company_id' => true, 'address_header_id' => true, 'name' => true, ]; and address_header table entity protected $_accessible = [ 'id' => true, 'user_id' => true, 'company_id' => true, 'created_date' => true, ];
# Mar 12th 2018, 07:11 joddit Can check the FormHpage for how to structure associated data https://book.cakephp.org/3.0/en/views/helpers/form.html#creating-inputs-for-associated-data
# Mar 12th 2018, 07:11 joddit Something like this https://gist.github.com/anonymous/3201973ab3ab52023829d66bd2d5ee2b
# Mar 12th 2018, 07:09 joddit of addresses, not a single address
# Mar 12th 2018, 07:09 joddit your 'addresses key should be an indexed array
# Mar 12th 2018, 07:06 joddit Maybe your 'address' key needs to be 'addresses'[0]
# Mar 12th 2018, 07:06 joddit Since it's not a hasOne
# Mar 12th 2018, 07:06 joddit Try formatting your data differently
# Mar 12th 2018, 07:04 joddit My guess is, it is ignoring your address data
# Mar 12th 2018, 07:04 joddit See if the fields are even being caught and marked dirty
# Mar 12th 2018, 07:04 joddit Check your entity
# Mar 12th 2018, 07:04 joddit Hrmm
# Mar 12th 2018, 07:04 aneh i get same result even if i set atomic=> false
# Mar 12th 2018, 07:04 joddit Well your association code look proper, the data that you're attempting to save looks proper and the controller code looks proper to be honest.
# Mar 12th 2018, 07:00 aneh Cake is not save data in address table
# Mar 12th 2018, 06:59 aneh File uploaded https://cakesf.slack.com/files/U2KMFH4MR/F9MG3K4C8/screen_shot_2018-03-12_at_12.29.20_pm.png / https://slack-files.com/T053DPNCM-F9MG3K4C8-17c5877df5
# Mar 12th 2018, 06:58 joddit Or she*
# Mar 12th 2018, 06:58 joddit Hopefully savant chimes in... He'll know
# Mar 12th 2018, 06:57 joddit Maybe you have to 'atomic' => false since the transaction would stop the ID from being generated, dunno
# Mar 12th 2018, 06:55 joddit Have you checked if they're being marked dirty?
# Mar 12th 2018, 06:55 joddit ects using this key by making the custom options the array value. If false no associated records will be saved. (default: true)"
# Mar 12th 2018, 06:55 joddit Fromt he API docs... "associated: If true it will save 1st level associated entities as they are found in the passed $entity whenever the property defined for the association is marked as dirty. If an array, it will be interpreted as the list of associations to be saved. It is possible to provide different options for saving on associated table obj