Log message #4268004

# At Username Text
# Jul 20th 2021, 19:28 slackebot2 custom fields in the api. I am still getting familiar with the cake event system and middleware. would pre-processing a request body be something I use middleware for? A before render event on the output side?
# Jul 20th 2021, 19:28 jadelbe418 I am working on a custom fields integration for a CakePHP Rest/ Crud based API. It has a slightly sophisticated MySQL schema architecture to allow users to create their own fields on certain tables in the system. I need to be able to filter posted json data and reformat it for the cake orm on a request so it properly fits into the cake schema and reformat it on the way out so the custom fields display consistently with non
# Jul 20th 2021, 15:53 kevin.pfeifer so you don't change your datasoure in your tests via the $connection variable? https://book.cakephp.org/3/en/development/testing.html#creating-fixtures
# Jul 20th 2021, 15:30 martin when I add `test_pipedrive` to the WebServices array and set Classname and Service it works fine. but I have multiple webservices. No problems with them, only with the newest one
# Jul 20th 2021, 15:29 kevin.pfeifer well to answer your question
# Jul 20th 2021, 15:29 kevin.pfeifer you are right :thinking_face:
# Jul 20th 2021, 15:28 martin not sure, default version by cakephp 3.9 I think?
# Jul 20th 2021, 15:27 kevin.pfeifer is it just me or is phpunit 6.5 pretty old? ,:)
# Jul 20th 2021, 15:24 martin would be nice if --debug did give me some debug information
# Jul 20th 2021, 15:17 martin ```vendor/bin/phpunit --debug PHPUnit 6.5.14 by Sebastian Bergmann and contributors. Exception: The datasource configuration "test_pipedrive" was not found. in [/var/www/vendor/cakephp/cakephp/src/Datasource/ConnectionManager.php, line 195]``` How can I fix this issue? pipedrive is a webservice not a database. so can’t really add a test_pipedrive resource? Also have no tests that require that
# Jul 20th 2021, 13:05 sebastiansperandio093 thanks kevin!
# Jul 20th 2021, 12:22 paolo.bragagni yes thank you!!
# Jul 20th 2021, 12:14 ndm Good... for reference, here's an overview of the field formats for the different association types: https://book.cakephp.org/4/en/views/helpers/form.html#associated-form-inputs
# Jul 20th 2021, 12:11 paolo.bragagni :)
# Jul 20th 2021, 12:11 paolo.bragagni it works
# Jul 20th 2021, 12:11 ndm You just need to change the field name.
# Jul 20th 2021, 12:10 paolo.bragagni hum
# Jul 20th 2021, 12:10 ndm what... no! That array format was just to illustrate what the data will look like in the request.
# Jul 20th 2021, 12:08 paolo.bragagni so in this way? $this->Form->hidden('books',['value' => ['categories' => [['id' => 'value']]]])
# Jul 20th 2021, 12:05 paolo.bragagni I check it all
# Jul 20th 2021, 12:04 paolo.bragagni yes
# Jul 20th 2021, 12:04 slackebot2 more categories.
# Jul 20th 2021, 12:04 ndm So it's actually `hasMany`, not `belongsToMany`? And you create a new books record, meaning there is no existing associated data that would need to be modified, and only this one hidden category should be added? Then the field name format would be `categories.0.id` (which translates to `['categories' => [['id' => 'value']]`). But you might get into trouble if there possibly also is a visible control where users can choose one or
# Jul 20th 2021, 11:59 paolo.bragagni (in my old cake2 project echo "\t\t\t echo \$this->Form->hidden('{$assocName}', array('hiddenField' => true, 'value'=> \$f_id));\n"; worked...)
# Jul 20th 2021, 11:58 paolo.bragagni everything is working but the add, because when I add a book from that view it has to select category=2 (in hidden field)
# Jul 20th 2021, 11:57 paolo.bragagni I've done a bake template that build that in the 'view' view
# Jul 20th 2021, 11:56 paolo.bragagni books (libri) habtm categories
# Jul 20th 2021, 11:56 paolo.bragagni
# Jul 20th 2021, 11:55 paolo.bragagni my goal is this (call me crazy)
# Jul 20th 2021, 11:54 paolo.bragagni I have the value already in the view
# Jul 20th 2021, 11:53 dereuromark Right before saving :)
# Jul 20th 2021, 11:51 paolo.bragagni :S
# Jul 20th 2021, 11:41 dereuromark Most of hidden fields could Actually be added directly in Controller. Removes usually some of the tempering and complexitity vectors
# Jul 20th 2021, 11:37 paolo.bragagni in Books 'add1' view I'd like to save one specific category
# Jul 20th 2021, 11:36 paolo.bragagni Books has many Categories
# Jul 20th 2021, 11:20 ndm The `_ids` key is not ment to hold a flat value, but an array of values. You probably need to be a bit more specific as to where exactly in your associated data you want to store something, and what that something actually looks like (data structure wise).
# Jul 20th 2021, 10:54 paolo.bragagni I mean I'd like to save a specific value with an hidden field
# Jul 20th 2021, 10:25 paolo.bragagni I'd like to save $return['returncontrollerid']
# Jul 20th 2021, 10:24 paolo.bragagni echo $this->Form->hidden('{{ assocData.property }}._ids', ['value' => $return['returncontrollerid']]);
# Jul 20th 2021, 10:24 paolo.bragagni hi how to save specific value in form BelongsToMany?
# Jul 20th 2021, 10:08 dereuromark here it is twice as important to check that all incoming values are properly sanitized though. and there is no room for "injection" of any kind of data.