# |
Jun 29th 2021, 12:38 |
dereuromark |
Have Users and Books both tags? That might explain it. Here you need to indeed tell the behavior to alias the respective junction assocs, to make sure they are unique (Tagged => XTagged and YTagged) |
# |
Jun 29th 2021, 12:36 |
kevin.pfeifer |
well do you have tests written for your app? |
# |
Jun 29th 2021, 12:36 |
conehead |
And I just had the case with saving now, where it does not even throw an error, just ignores and does not save the tags. |
# |
Jun 29th 2021, 12:35 |
conehead |
Pretty much every entity on my software uses Tags :( And I think this might affect everything that finds/saves Entities through other Tables. So I gotta be afraid that something is not working anymore whenever I use $this->Table1->Table2->find/save |
# |
Jun 29th 2021, 12:34 |
slackebot |
happening? I don't want directory name in my url. Is it a problem with my .htaccess or cakephp config or something else? |
# |
Jun 29th 2021, 12:34 |
slackebot |
(from <https://book.cakephp.org/4/en/installation.html#apache>) I can access all routes and files with proper urls but there is a problem. Whenever i use Url helper it appends the directory name to the url. For example doing `$this->Url->build('/')` gives me `domain.com/subdirectory` instead of `domain.com/`. Both of those url work when i open them in browser. How can i stop this from |
# |
Jun 29th 2021, 12:34 |
theblackbird.eu |
Hello, I'm struggling with urls in Cakephp 4 and hope someone can help. Due to how server is set up i have to use .htaccess to redirect everything for a domain from root folder to subdirectroy - i sadly can't change that. I have my .htaccess set up and it seems to be working: <https://pastebin.com/Nt6cXjiQ> Both app root and webdirectory .htaccess are default |
# |
Jun 29th 2021, 12:33 |
kevin.pfeifer |
well If you don't use any other BelongsToMany associations with the same alias on multiple tables you should be fine |
# |
Jun 29th 2021, 12:31 |
conehead |
it screws up other stuff. This is just one case I found |
# |
Jun 29th 2021, 12:31 |
conehead |
My problem is not how to fix it...my problem is more that I don't know if |
# |
Jun 29th 2021, 12:29 |
kevin.pfeifer |
why it works one way but not the other could be a bug |
# |
Jun 29th 2021, 12:29 |
kevin.pfeifer |
I would guess the easiest solution for you would be to define one association as UserTags and one as BookTags |
# |
Jun 29th 2021, 12:28 |
conehead |
And the targets differs. Both Tables use "Tags" and that is the reason why it does fail when finding through an association |
# |
Jun 29th 2021, 12:26 |
conehead |
Yes |
# |
Jun 29th 2021, 12:26 |
kevin.pfeifer |
well this only means, that there is an association present with the same alias but different targets or foreignkeys |
# |
Jun 29th 2021, 12:21 |
conehead |
Not sure if it should be this way or if this breaks other stuff for me as well :( |
# |
Jun 29th 2021, 12:20 |
conehead |
https://github.com/cakephp/cakephp/commit/1335605f8c68e7bac19cbc1028e6e7c7f2b479fa |
# |
Jun 29th 2021, 12:03 |
conehead |
But the point is, it is working with the TableLocator, but not with the association. Just trying to find out what changed with cake 4.1 |
# |
Jun 29th 2021, 12:02 |
conehead |
Ah yes, the find is missing in the second |
# |
Jun 29th 2021, 12:02 |
conehead |
Yes, Users and Books have "Tags" defined. There is no real custom configuration |
# |
Jun 29th 2021, 11:58 |
dereuromark |
or 4.1 - but the 2nd one doesn't even issue a find(), that's weird.. this shouldn't even be working IMO |
# |
Jun 29th 2021, 11:56 |
dereuromark |
4.2 is a bit more strict. Looks like you defined it somewhere else already, and the plugin sets up its own relations by default. best to rename the custom ones you set up or remove them etc. |
# |
Jun 29th 2021, 11:55 |
conehead |
Yes that behavior |
# |
Jun 29th 2021, 11:53 |
kevin.pfeifer |
or is it a custom behavior you created? |
# |
Jun 29th 2021, 11:50 |
kevin.pfeifer |
you mean from the behavior from this plugin? https://github.com/dereuromark/cakephp-tags |
# |
Jun 29th 2021, 11:36 |
conehead |
Happens when upgrading from 4.0.5 to 4.1.7 |
# |
Jun 29th 2021, 11:33 |
erwane |
You can set defaultConnection in your Model table class. If your Datasource support SQL, yes, you can use the ORM but maybe it need a special driver. |
# |
Jun 29th 2021, 11:33 |
conehead |
Both tables are using the Tags behaviorBoth tables are using the Tags behavior |
# |
Jun 29th 2021, 11:33 |
conehead |
Hmm i just tried upgrading to Cake 4.2 and suddenly I get with my Tags plugin: "The existing `Tags` association on `Tagged` is incompatible with the `Tags` association on...`" This happens when I try to find an entity ```$this->Users->Books->find()->contain(['Tags'])->first(); // this does not work and I get the error TableRegistry::getTableLocator()->get('Books')->contain(['Tags'])->first(); // this does work``` |
# |
Jun 29th 2021, 11:14 |
paolo.bragagni |
ok thanks you are great |
# |
Jun 29th 2021, 11:11 |
kevin.pfeifer |
as in the index.twig |
# |
Jun 29th 2021, 11:11 |
kevin.pfeifer |
bellow you have basically the same foreach but just with the BelongsToMany https://github.com/cakephp/bake/blob/2.5.1/templates/bake/element/form.twig#L64 |
# |
Jun 29th 2021, 11:09 |
kevin.pfeifer |
```{%- if fieldData.null %}``` just checks if the given field can be empty/null or not |
# |
Jun 29th 2021, 11:09 |
ndm |
That check has nothing to do with associations, but whether the field is nullable |
# |
Jun 29th 2021, 11:07 |
paolo.bragagni |
to desume that field is associated to some other table |
# |
Jun 29th 2021, 11:07 |
paolo.bragagni |
{%- set fieldData = Bake.columnData(field, schema) %} {%- if fieldData.null %} |
# |
Jun 29th 2021, 11:07 |
paolo.bragagni |
it checks |
# |
Jun 29th 2021, 11:06 |
paolo.bragagni |
in form.twig the cicle is quite different |
# |
Jun 29th 2021, 11:04 |
paolo.bragagni |
ok more or less I've understand BUT |
# |
Jun 29th 2021, 11:02 |
kevin.pfeifer |
https://github.com/cakephp/bake/blob/2.5.1/templates/bake/Template/index.twig#L43 |
# |
Jun 29th 2021, 11:02 |
kevin.pfeifer |
well the details variable is part of the foreach a few lines above |