# |
Sep 20th 2019, 14:21 |
neon1024 |
Maybe have the postlink to go to a new method? |
# |
Sep 20th 2019, 14:20 |
spriz |
Oh welp, I'll hack it for now :shrug: |
# |
Sep 20th 2019, 14:20 |
spriz |
but getting there with an `''` could mean lots of things |
# |
Sep 20th 2019, 14:20 |
spriz |
so all it does is post with `'image' => ''` |
# |
Sep 20th 2019, 14:20 |
spriz |
we have a postLink in our case to delete the image, |
# |
Sep 20th 2019, 14:19 |
neon1024 |
An extra checkbox feels like an approach which confirms the users intention |
# |
Sep 20th 2019, 14:19 |
spriz |
Exactly |
# |
Sep 20th 2019, 14:19 |
neon1024 |
Indeed, as empty might mean “I don’t want to change this” instead of “Delete this property” |
# |
Sep 20th 2019, 14:19 |
spriz |
Yeah, I'm just not too sure what the best approach would be |
# |
Sep 20th 2019, 14:19 |
neon1024 |
Perhaps it’s worth a PR, it does feel like a missing feature |
# |
Sep 20th 2019, 14:18 |
spriz |
yeah, it is for our other usage |
# |
Sep 20th 2019, 14:18 |
neon1024 |
https://github.com/FriendsOfCake/cakephp-upload/blob/master/src/Model/Behavior/UploadBehavior.php#L121 |
# |
Sep 20th 2019, 14:18 |
neon1024 |
Well it does but it assumes that the file is an association |
# |
Sep 20th 2019, 14:17 |
spriz |
yeah but it feels like it was not intended just to delete whatever the plugin put there in first case :) |
# |
Sep 20th 2019, 14:17 |
neon1024 |
Creating a Writer class is an intended customization path with the plugin though |
# |
Sep 20th 2019, 14:17 |
neon1024 |
You might be, I’m not an expert with the plugin having written my own :slightly_smiling_face: |
# |
Sep 20th 2019, 14:16 |
spriz |
I hoped I was missing something obvious :shrug: |
# |
Sep 20th 2019, 14:16 |
spriz |
Yeah, I just feel like this should be easily doable without weird hacks :) |
# |
Sep 20th 2019, 14:16 |
neon1024 |
Perhaps implement your own Writer class which copes with this use-case? |
# |
Sep 20th 2019, 14:15 |
neon1024 |
Maybe ask @savant |
# |
Sep 20th 2019, 14:15 |
spriz |
I could put `0` and make `if (empty($user->image)) { $user->image = null; }` |
# |
Sep 20th 2019, 14:15 |
neon1024 |
So in `beforeMarshal` you could fix the request data |
# |
Sep 20th 2019, 14:15 |
spriz |
I guess so ,:) |
# |
Sep 20th 2019, 14:15 |
neon1024 |
So if you passed a null upload array with `UPLOAD_ERR_OK` set as the error you’d pass the condtion? |
# |
Sep 20th 2019, 14:15 |
neon1024 |
`!== UPLOAD_ERR_OK` |
# |
Sep 20th 2019, 14:14 |
spriz |
but feels bad not just to use the existing `edit($id)` |
# |
Sep 20th 2019, 14:14 |
spriz |
or make a controller action `removeImage($userId)` |
# |
Sep 20th 2019, 14:14 |
spriz |
Hmm, feels so hackish, but I guess that;s the way to go |
# |
Sep 20th 2019, 14:13 |
neon1024 |
Events have that priority number, so you could put your one higher? |
# |
Sep 20th 2019, 14:13 |
spriz |
https://github.com/FriendsOfCake/cakephp-upload/blob/master/src/Model/Behavior/UploadBehavior.php#L90-L96 |
# |
Sep 20th 2019, 14:13 |
neon1024 |
Er, `beforeSave` even maybe |
# |
Sep 20th 2019, 14:13 |
spriz |
it does so in `beforeSave` :S |
# |
Sep 20th 2019, 14:13 |
neon1024 |
`afterMarshal`? |
# |
Sep 20th 2019, 14:13 |
jotpe |
hm |
# |
Sep 20th 2019, 14:13 |
spriz |
the behavior puts the right one back, then :) |
# |
Sep 20th 2019, 14:13 |
neon1024 |
Set the property to null and mark it dirty? |
# |
Sep 20th 2019, 14:12 |
spriz |
Does anyone have a trick to remove the reference to an uploaded file on a table with `josegonzales/cakephp-upload`? I have `image` on `users` table, and want to remove it with patchEntity |
# |
Sep 20th 2019, 14:12 |
luizcmarin |
IMPORTANT Question: After upgrading to version 4, should I regenerate the application? composer create-project --prefer-dist cakephp / app? I imagine you have changed things in that regard as well. How would this line look to recreate the application? |
# |
Sep 20th 2019, 14:03 |
neon1024 |
Well, I mean on a ‘base url’ rather than a controller obviously |
# |
Sep 20th 2019, 14:03 |
daniel.upshaw |
Also tried dc.usersdemo as well |
# |
Sep 20th 2019, 14:03 |
neon1024 |
Can I enable fallback routes on a per controller basis without using a prefix? |