# |
Feb 14th 2018, 11:22 |
Guest65 |
I think in most cases model is usually plural. So just recheck if $this->Tag is indeed same or maybe $this->Tags |
# |
Feb 14th 2018, 11:22 |
saeideng |
``` $tag = $this->Tag->find()->where(['id'=>$id])->first(); if($tag){ ``` |
# |
Feb 14th 2018, 11:21 |
Guest65 |
Ah! You want to read it too |
# |
Feb 14th 2018, 11:21 |
saeideng |
`$this->Tag->get($id) === $this->Tag->find()->where(['id'=>$id])->firstOrFail();` |
# |
Feb 14th 2018, 11:21 |
Guest65 |
It should be more like `$tagExist = ($this->Tags->find('all', 'conditions' => ['id' => $id])->count() > 0) |
# |
Feb 14th 2018, 11:21 |
dinosaur |
@saeideng ok then. Thanks |
# |
Feb 14th 2018, 11:20 |
saeideng |
without throwing exception |
# |
Feb 14th 2018, 11:20 |
saeideng |
you can use `$this->Tag->find()->where(['id'=>$id])->first();` |
# |
Feb 14th 2018, 11:19 |
saeideng |
what? |
# |
Feb 14th 2018, 11:18 |
dinosaur |
@saeideng so try/catch is required... |
# |
Feb 14th 2018, 11:17 |
saeideng |
>the line "$tag = $this->Tag->get($id)" should raise exception if $id is not found?? yes |
# |
Feb 14th 2018, 11:15 |
dinosaur |
A very basic question: in a controller, the line "$tag = $this->Tag->get($id)" should raise exception if $id is not found??? I need to use try/catch just to read (or not) a record? This is the expected behaviour ? |
# |
Feb 14th 2018, 11:15 |
dinosaur |
good morning(?) |
# |
Feb 14th 2018, 11:11 |
jameg83 |
It’s probably easier to write 2 template files. One for local and one for live. Horrible and messy but it’ll work. |
# |
Feb 14th 2018, 11:07 |
hmic |
well, the segmentation fault is where you start searching now - and the reason your browser freezes i guess :p |
# |
Feb 14th 2018, 10:39 |
jameg83 |
Could it be the current working directory flag for wkhtmltopdf? |
# |
Feb 14th 2018, 10:15 |
slackebot |
different environments. Also I saved the html file, left my dev server running and the tried to convert to pdf via the command line and got a “segmentation fault” error and no pdf... |
# |
Feb 14th 2018, 10:15 |
jameg83 |
@hmic (IRC) I told a fib earlier, when I run my template as html the image doesn’t load. If I change my img src to (http://localhost:8765/img/image.png) when running as a html file it works. When running with the .pdf extension I have to change the img src to (/home/jamesg83/NetBeansProjects/project/webroot/img/image.png) and that works fine too. If I can’t find a solution I’ll have to extend the html helpers to write my paths for the |
# |
Feb 14th 2018, 09:43 |
k4t |
yeah |
# |
Feb 14th 2018, 09:43 |
Guest65 |
Ah! It's funny. I have never collections before until today :p |
# |
Feb 14th 2018, 09:41 |
neon1024 |
I would use sort with a callback and use my own method, similar to usort() |
# |
Feb 14th 2018, 09:36 |
k4t |
no sql involved :P |
# |
Feb 14th 2018, 09:36 |
k4t |
I need to sort collection, no results from database |
# |
Feb 14th 2018, 09:35 |
Guest65 |
https://stackoverflow.com/questions/32398462/cakephp-3-how-to-add-order-in-querybuilder-for-associative-data |
# |
Feb 14th 2018, 09:34 |
k4t |
I think it is not supported by cake at the moment |
# |
Feb 14th 2018, 09:33 |
k4t |
no, sortBy can take only fieldname or callback |
# |
Feb 14th 2018, 09:32 |
Guest65 |
slackebot I think you can use array in sort key |
# |
Feb 14th 2018, 09:32 |
k4t |
Hi guys, how I can sort Collection with multiple fields? |
# |
Feb 14th 2018, 09:31 |
Guest65 |
Quick question. If I have a table "alphas_betas", should foreign key to its id be called "aphas_beta_id" or "aplha_beta_id"? |
# |
Feb 14th 2018, 09:30 |
Guest65 |
Hi |
# |
Feb 14th 2018, 08:47 |
admad |
in general to debug saving issues debug() the patched entity |
# |
Feb 14th 2018, 08:45 |
admad |
if the former make sure "roles" is in accessible list in the User entity |
# |
Feb 14th 2018, 08:44 |
admad |
LubosR: do you have problem just saving the associations or other fields too? |
# |
Feb 14th 2018, 08:43 |
neon1024 |
Morning |
# |
Feb 14th 2018, 08:37 |
LubosR |
Looks like my form is not saved even when I am not using crud :-/ |
# |
Feb 14th 2018, 08:32 |
LubosR |
Any ideas? |
# |
Feb 14th 2018, 08:31 |
LubosR |
Here is how my method looks like and output of request data https://gist.github.com/LubosRemplik/88b8dcfe0c26a25baa6af2d7c0a1f4b0 |
# |
Feb 14th 2018, 08:25 |
LubosR |
In the UsersTable I have many to many association with Roles (works fine with find) and in Controller initialize where I am loading Crud plugin I am using relatedModels listener |
# |
Feb 14th 2018, 08:24 |
LubosR |
I have form control like multiple select here https://book.cakephp.org/3.0/en/views/helpers/form.html#creating-inputs-for-associated-data with roles._ids |
# |
Feb 14th 2018, 08:24 |
LubosR |
Hey all, i have problem to save many to many data with crud plugin - anybody give me a hint? |
# |
Feb 14th 2018, 08:08 |
hmic |
moin |