Tried to post more details. Forum response was: An error occurred: Sorry, new users can only mention 2 users in a post.
Version: 5.2.5
Same code works in Version: 4.5.8 This is not a migration, clean install.
I have stripped down the controller and model for trouble shooting. My confusion is why is cake trying to _mergeAssociation.
Same error when getting the entity by primary key $company = $this->Companies->get($id);
If I remove the select list from edit form, entity posts successfully.
If I remove the hasOne Association, entity posts successfully.
But the return view errors because of the missing association.
Full error:
2025-07-10 12:55:57 error: [TypeError] Cake\ORM\Marshaller::_mergeAssociation(): Argument #1 ($original) must be of type Cake\Datasource\EntityInterface|array|null,
int given, called in /var/www/vhosts/dpg3.schillers.com/app/vendor/cakephp/cakephp/src/ORM/Marshaller.php on line 123 in /var/www/vhosts/dpg3.schillers.com/app/vendor/cakephp/cakephp/src/ORM/Marshaller.php on line 752
Stack Trace:
- CORE/src/ORM/Marshaller.php:123
- CORE/src/ORM/Marshaller.php:603
- CORE/src/ORM/Table.php:3056
- APP/Controller/CompaniesController.php:1187
- CORE/src/Controller/Controller.php:505
- CORE/src/Controller/ControllerFactory.php:166
- CORE/src/Controller/ControllerFactory.php:141
- CORE/src/Http/BaseApplication.php:362
- CORE/src/Http/Runner.php:86
- CORE/src/Http/Middleware/CsrfProtectionMiddleware.php:169
- CORE/src/Http/Runner.php:82
- ROOT/vendor/cakephp/authentication/src/Middleware/AuthenticationMiddleware.php:106
- CORE/src/Http/Runner.php:82
- CORE/src/Http/Middleware/BodyParserMiddleware.php:162
- CORE/src/Http/Runner.php:82
- CORE/src/Routing/Middleware/RoutingMiddleware.php:117
- CORE/src/Http/Runner.php:82
- CORE/src/Routing/Middleware/AssetMiddleware.php:70
- CORE/src/Http/Runner.php:82
- CORE/src/Error/Middleware/ErrorHandlerMiddleware.php:115
- CORE/src/Http/Runner.php:82
- ROOT/vendor/cakephp/debug_kit/src/Middleware/DebugKitMiddleware.php:60
- CORE/src/Http/Runner.php:82
- CORE/src/Http/Runner.php:60
- CORE/src/Http/Server.php:104
- ROOT/webroot/index.php:37
- [main]:
My guess would be, that you need to make adjustments in your template (which is responsibie for the structure of data you get via $this->Form->control() etc.)
My concern now is that I am trying to do something with my model that is breaking cake.
Should I switch my focus their and provide details in that area.
Kevin, I really do appreciate your input!
I had three hasOne associations that when I appended the “_key” in the table column, table and the form, all started working. Example: Changed “tax_cod” to “tax_cod_key”
No idea why this logic worked in v4.5.8 and not in v5.2.5. Naming conventions???
The duplicate naming is the problem. On the entity, the field tax_code would map to the tax_code db column but then you used the same name for the association property, so it would get overwritten with the associated entity instance.
If you want to keep the db column same then you need to use a different association property name.