# |
Jan 7th 2020, 18:49 |
this.impetus |
I don't either! sec |
# |
Jan 7th 2020, 18:49 |
ndm |
I don't really understand what's failing... do you get any errors? What does `debug($publication)` show after patching? |
# |
Jan 7th 2020, 18:47 |
this.impetus |
I mean I simpler way to say this is that I want to create a new Publication, and at the same time save it's associated authors, and the join table needs two extra fields. I either don't know how to write that form, or else, if the sample data I provided appears correctly formatted, I'm failing on the controller end before the call to `Controller->save()` but I don't understand how. |
# |
Jan 7th 2020, 18:44 |
this.impetus |
The authors array arrives at the controller as shown, and the the last attempt at the `patchEntity` call is actually what's happening; still, the record isn't created and instead bounced back to controller/add |
# |
Jan 7th 2020, 18:43 |
this.impetus |
No, lol, sorry; the example I provided had mistakes, it was poor form of me because I modified it for chat and thus added those mistakes |
# |
Jan 7th 2020, 18:32 |
ndm |
Soooooo... it's working now? |
# |
Jan 7th 2020, 18:24 |
this.impetus |
... ok, to clarify, I need to use this logic for a bunch of different models, including `Grants`, which makes less immediate sense than `Publications`; again, this line isn't hot garbage in app and should have read: ```$publication = $this->Publications->patchEntity( $publication, $this->request->getData(), ['associated' =>['Authors']] );``` |
# |
Jan 7th 2020, 18:18 |
this.impetus |
Note: this isn't actually spelled wrong in my code, `$publication = $this->Publicationss` lol |
# |
Jan 7th 2020, 18:16 |
slackebot |
]``` to no avail. |
# |
Jan 7th 2020, 18:16 |
this.impetus |
I've also tried this ```'authors' => [ (int) 0 => [ '_joinData' => [ 'ordinance' => '1', 'principle_investigator' => 'false', 'starred' => 'true' ] ], (int) 1 => [ '_joinData' => [ 'ordinance' => '2', 'principle_investigator' => 'false', 'starred' => 'true' ] ], (int) 2 => [ '_joinData' => [ 'ordinance' => '3', 'principle_investigator' => 'false', 'starred' => 'true' ] ] |
# |
Jan 7th 2020, 18:13 |
this.impetus |
the form controls are dynamically generated, but I *think* I have them right, now, unless `_joinData[starred]` shouldn't have a value |
# |
Jan 7th 2020, 18:11 |
this.impetus |
and in my controller I have: ` ```$publication = $this->Publicationss->patchEntity( $grant, $this->request->getData(), ['associated' =>['Authors']] );```` |
# |
Jan 7th 2020, 18:11 |
slackebot |
'principle_investigator' => 'false', '_joinData' => [ 'starred' => 'true' ] ] ] ``` |
# |
Jan 7th 2020, 18:11 |
slackebot |
table has two extra fields. Here's the `authors` key of the request data : ```'authors' => [ (int) 0 => [ 'id' => '17', 'ordinance' => '1', 'principle_investigator' => 'false', '_joinData' => [ 'starred' => 'true' ] ], (int) 1 => [ 'id' => '7', 'ordinance' => '2', 'principle_investigator' => 'false', '_joinData' => [ 'starred' => 'true' ] ], (int) 2 => [ 'id' => '4', 'ordinance' => '3', |
# |
Jan 7th 2020, 18:11 |
this.impetus |
Heya guys, I was in here yesterday trying to figure out how make a form that would manage HABTM associations with more than the standard id fields. Got directed here: https://book.cakephp.org/3/en/views/helpers/form.html#creating-inputs-for-associated-data and made some headway. But I'm still failing to create the record when the aassocations are included. Just to make it easier to talk about, Publications HABTM Authors; but their join |
# |
Jan 7th 2020, 16:44 |
ndm |
no problem |
# |
Jan 7th 2020, 16:44 |
damiano |
perfect thank you! |
# |
Jan 7th 2020, 16:43 |
damiano |
ok |
# |
Jan 7th 2020, 16:43 |
damiano |
because of the name of the plugin i think |
# |
Jan 7th 2020, 16:43 |
ndm |
use a slash only `/` |
# |
Jan 7th 2020, 16:43 |
damiano |
the route still works with test.localhost/webhook/ <-- |
# |
Jan 7th 2020, 16:43 |
damiano |
the problem is that if i remove the 'path' |
# |
Jan 7th 2020, 16:42 |
damiano |
$routes->plugin( 'Webhook', ['path' => '/webhook',], <---- i need to remove this |
# |
Jan 7th 2020, 16:42 |
damiano |
@ndm last thing... |
# |
Jan 7th 2020, 16:42 |
damiano |
@ndm you are right :) |
# |
Jan 7th 2020, 16:41 |
damiano |
if i do foo3.localhost/webhook/my-controller/action works too and so on... |
# |
Jan 7th 2020, 16:41 |
ndm |
You probably still have the fallbacks connected |
# |
Jan 7th 2020, 16:41 |
damiano |
if i do foo2.localhost/webhook/my-controller/action works too |
# |
Jan 7th 2020, 16:41 |
damiano |
if i do foo1.localhost/webhook/my-controller/action works |
# |
Jan 7th 2020, 16:40 |
damiano |
@ndm strange thing happen....i can reach the controller but i can use whatever subdomain i want |
# |
Jan 7th 2020, 16:37 |
damiano |
let me check |
# |
Jan 7th 2020, 16:37 |
damiano |
ok |
# |
Jan 7th 2020, 16:36 |
damiano |
in my Application.php there is $this->addPlugin('Webhook'); |
# |
Jan 7th 2020, 16:36 |
ndm |
It would be `test.localhost/webhook/...` |
# |
Jan 7th 2020, 16:36 |
damiano |
if i do test.localhost i always see the pages/home.ctp |
# |
Jan 7th 2020, 16:35 |
damiano |
@ndm by the wway when i run the local server bin/cake server i cannot reach that controller |
# |
Jan 7th 2020, 16:35 |
ndm |
I wouldn't necessarily call it a bug, more like a missing feature. Thing is, `_method` for example is set in the routing defaults, while `_host` is an option. |
# |
Jan 7th 2020, 16:30 |
damiano |
@ndm do you mean bin/cake routes has a bug (maybe) ? |
# |
Jan 7th 2020, 16:29 |
ndm |
I'm not sure why that is, maybe `_host` is somewhat special, or it's missing by accident |
# |
Jan 7th 2020, 16:25 |
slackebot |
{"action":"index","plugin":"Webhook"} |
# |
Jan 7th 2020, 16:25 |
damiano |
webhook._controller:_action | /webhook/{controller}/{action}/* | {"action":"index","plugin":"Webhook"} | | webhook._controller:index | /webhook/{controller} | {"action":"index","plugin":"Webhook"} | | webhook._controller:_action | /webhook/{controller}/{action}/* | |