# |
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 |
# |
Mar 12th 2018, 06:53 |
joddit |
I usually just save the initial parent record, then user $entity->id to populate the associations and save them that way |
# |
Mar 12th 2018, 06:52 |
joddit |
Checking the API docs rq |
# |
Mar 12th 2018, 06:52 |
joddit |
Examples in the book in the docs only show saving associations on existing records, not creating both initial record and associations at same time |
# |
Mar 12th 2018, 06:50 |
aneh |
wait will post sql here |
# |
Mar 12th 2018, 06:49 |
joddit |
Did it even attempt the insert for the address record(s)? |
# |
Mar 12th 2018, 06:49 |
joddit |
Did you check the SQL log in debugkit? |
# |
Mar 12th 2018, 06:48 |
aneh |
you can check here |
# |
Mar 12th 2018, 06:48 |
aneh |
https://stackoverflow.com/questions/49229158/error-saving-associated-data-cakephp-3 |
# |
Mar 12th 2018, 06:48 |
aneh |
i did not get any error from cakephp but it did not create entry on address table |
# |
Mar 12th 2018, 06:46 |
joddit |
Are you updating an existing record or creating a new record? |
# |
Mar 12th 2018, 06:45 |
joddit |
Please |
# |
Mar 12th 2018, 06:45 |
joddit |
Would be easier if you pasted the error with structure somewhere like https://gist.github.com/ |
# |
Mar 12th 2018, 06:41 |
slackebot |
} We need to save multiple address under one address header id. when i run above code it create entry in address_header but did not make any entry in addresses table. |
# |
Mar 12th 2018, 06:41 |
slackebot |
'company_id' => 4, 'name' => 'Aneh' ] ]; $entity = $this->AddressHeaders->newEntity(); $entity = $this->AddressHeaders->patchEntity($entity, $data, [ 'associated' =>['Addresses'] ]); if($this->AddressHeaders->save($entity)){ echo "save"; }else{ pr($entity->errors()); |
# |
Mar 12th 2018, 06:41 |
aneh |
Error saving associated data AddressHeadersTable $this->hasMany('Addresses', [ 'foreignKey' => 'address_header_id' ]); AddressesTable $this->belongsTo('AddressHeaders', [ 'foreignKey' => 'address_header_id', ]); Controller Code $data = [ 'user_id' => 1, 'company_id' => 4, 'address' => [ 'user_id' => 1, |
# |
Mar 12th 2018, 05:29 |
savant |
strange |
# |
Mar 12th 2018, 05:13 |
angelxmoreno |
i'm doritos? :nerd_face: |
# |
Mar 12th 2018, 05:13 |
savant |
im layz |
# |
Mar 12th 2018, 05:13 |
savant |
same |
# |
Mar 12th 2018, 05:13 |
angelxmoreno |
lmao |
# |
Mar 12th 2018, 05:13 |
angelxmoreno |
i was always a default routes kinda guy |
# |
Mar 12th 2018, 05:11 |
savant |
lots of people complained about not being able to remove them |
# |
Mar 12th 2018, 05:11 |
savant |
maybe 1.3 |
# |
Mar 12th 2018, 05:11 |
savant |
we added fallback routes in… 2.x? |
# |
Mar 12th 2018, 05:10 |
angelxmoreno |
sweet. +1 thing learned in Cake. all these years and still learning. love it |
# |
Mar 12th 2018, 05:10 |
angelxmoreno |
ok, it makes sense why i was getting the errors with the RouteCollection throwning exceptions |
# |
Mar 12th 2018, 05:09 |
savant |
or for cases where I dont want potentially duplicated content because i’ve defined a route for everything already |
# |
Mar 12th 2018, 05:09 |
angelxmoreno |
crap |
# |
Mar 12th 2018, 05:09 |
savant |
I do that for very small applications |
# |
Mar 12th 2018, 05:09 |
savant |
no fallbacks means you are explicitly defining routes |
# |
Mar 12th 2018, 05:08 |
angelxmoreno |
seems like with no fallbacks i get all sorts of errors |
# |
Mar 12th 2018, 05:08 |
joddit |
Uses the stock ones for the given scope, no? |
# |
Mar 12th 2018, 05:08 |
angelxmoreno |
i need to look into it more |
# |
Mar 12th 2018, 05:08 |
savant |
sure |
# |
Mar 12th 2018, 05:08 |
angelxmoreno |
does that make sense ? |
# |
Mar 12th 2018, 05:08 |
savant |
you can check the RouteCollection (?) class for the fallbacks method |
# |
Mar 12th 2018, 05:08 |
angelxmoreno |
``` $routes->prefix('api', function (RouteBuilder $routes) { $routes->connect('/finances/events', [ 'plugin' => 'Finances', 'controller' => 'Dashboard', 'action' => 'events', ]); $routes->fallbacks(DashedRoute::class); }); ``` |
# |
Mar 12th 2018, 05:08 |
savant |
the core ones |