Logs for #cakephp

Page 32 of 36,922, showing 100 records out of 3,692,143 total, starting on record 3,101, ending on 3,200

# At Username Text
# Jun 14th 2021, 19:55 kevin.pfeifer das integrierte Modal und “automatisch nachladen” find ich recht nett UX mäßig :)
# Jun 14th 2021, 19:55 kevin.pfeifer servus
# Jun 14th 2021, 19:54 kevin.pfeifer :,)
# Jun 14th 2021, 19:54 jh ach... rot weiss rot ist das nicht at ... mir sind alle flaggen immer wumpe :D
# Jun 14th 2021, 19:54 kevin.pfeifer the functional code (not the template) looks a bit like python for me
# Jun 14th 2021, 19:53 jh It is quite powerful language, very expressive
# Jun 14th 2021, 19:53 jh Haha :)
# Jun 14th 2021, 19:52 kevin.pfeifer what the hell is that syntax :,)
# Jun 14th 2021, 19:52 kevin.pfeifer oh god
# Jun 14th 2021, 19:50 kevin.pfeifer like when the bootstrap.php changes
# Jun 14th 2021, 19:50 kevin.pfeifer i like to keep my app up2date not only from a core library aspect but also from a base template aspect
# Jun 14th 2021, 19:50 kevin.pfeifer the one thing i “dont like” about cakephp is the fact, that I have to manually check the cakephp/app template if something “groundbreaking” has changed in e.g. the config folder
# Jun 14th 2021, 19:49 jh (but it is no stuff for shared hosts)
# Jun 14th 2021, 19:49 jh Let me know if you like Elixir/Phoenix :)
# Jun 14th 2021, 19:49 kevin.pfeifer oh well :)
# Jun 14th 2021, 19:49 jh I think I started with CakePHP 1.1 :)
# Jun 14th 2021, 19:49 jh And this one https://www.youtube.com/watch?v=JvBT4XBdoUE .. elixir is much more a general purpose tool, probably good for most but drivers and 3d engines, especially good for IOT (nerves) and web apps
# Jun 14th 2021, 19:48 kevin.pfeifer to be honest, i started with cake 3.0 and just gradually upgraded my main app over time. Just happened to have to “rewrite” a lot of code anyway when the 4.0 beta came out
# Jun 14th 2021, 19:48 jh yes I know cakephp for ages I just am used to maintain and extend 3.7-3.9 apps now and nothing more
# Jun 14th 2021, 19:47 kevin.pfeifer oho nice, will definitely watch that, thx
# Jun 14th 2021, 19:47 kevin.pfeifer but basically if you stick with the cakephp naming conventions you can easily generate your basic functionality :)
# Jun 14th 2021, 19:47 jh To just give you an impression https://www.youtube.com/watch?v=MZvmYaFkNJI
# Jun 14th 2021, 19:47 jh functional, process oriented, compiled (mostly)
# Jun 14th 2021, 19:46 kevin.pfeifer ok, never dipped into these lands :,)
# Jun 14th 2021, 19:46 jh Phoenix is Rails on Elixir
# Jun 14th 2021, 19:46 jh Elixir is glorified Erlang
# Jun 14th 2021, 19:45 kevin.pfeifer what the hell is even phoenix/elixir, never heard of that
# Jun 14th 2021, 19:44 kevin.pfeifer what If you remove the ```>prefix('Admin'``` and write your inner write with your patterns including the admin part? Like ``` $patterns = ['language' => 'en|ar']; $routes ->connect('/{language}/admin/:controller/:action/*', []) ->setPatterns($patterns);```
# Jun 14th 2021, 19:43 jh I ll write a new one - the alternative would be laravel + cakephp3 orm :D… sadly the project is too small for phoenix/elixir
# Jun 14th 2021, 19:41 slackebot <alamnaryab>
# Jun 14th 2021, 19:40 greg138 I try to answer the "easy" questions when I can, so that the real experts have time to answer mine. ;)
# Jun 14th 2021, 19:39 tomrwaller OK cool - I'll have a play around with both and see if I can get my head aound it. Thank you @greg138 and @kevin.pfeifer - you've both been really helpful. Concious I've been asking a lot of questions lately but this community has always gone above and beyond. It's much appreciated.
# Jun 14th 2021, 19:37 greg138 I mean, I think I like the `baselines_ids` solution better. It was empty, but that's because the field name didn't match what you had in the form. You said if you make the form match, then you have to set the label manually. I think that's the better solution.
# Jun 14th 2021, 19:37 alamnaryab I tried above without scope it is working for non-admin, but for admin how can I do where I need language parameter before admin prefix
# Jun 14th 2021, 19:36 tomrwaller I don't think so - as I mentioned, it's working as per your suggestion to use ['baselines']['_ids'].
# Jun 14th 2021, 19:35 greg138 Is there some other problem with using `baselines_ids` instead of `baselines._ids`?
# Jun 14th 2021, 19:35 greg138 Iterating through one array or another is a largely meaningless distinction IMO.
# Jun 14th 2021, 19:34 tomrwaller Gotcha - so would there be a better way - maybe some how iterate through the entities or something? Instead of dealing with the array of IDs?
# Jun 14th 2021, 19:33 greg138 If the only problem with the `baselines_ids` method is that the label isn't right on the input field, then just add `'label' => 'whatever'` when you create the input field.
# Jun 14th 2021, 19:33 kevin.pfeifer I only updated 1 CakePHP 3 app to 4 till now but I would say it mainly depends on how much custom code you have. If you stick to the generated code the bake console gave you then you will not have a hard time upgrading to cake4
# Jun 14th 2021, 19:32 greg138 Honestly, I don't love it. `._ids` is there for a specific use case, which is not the same as your use case. So, you are getting the functionality you want but it's basically because of a convenient side effect, not because you're using it as expected. To me, that brings with it a decent chance that somewhere along the line it will break because of changes made elsewhere, and it may take a while to notice that it's broken.
# Jun 14th 2021, 19:31 tomrwaller What would be the best way to debug that? I'm new (I still learning if that wasn't obvious already :) )
# Jun 14th 2021, 19:30 greg138 Then it's *probably* okay...
# Jun 14th 2021, 19:29 tomrwaller I'm not seeing any baselines being created if that's what you mean?
# Jun 14th 2021, 19:29 greg138 Just be careful to check that it really is working 100%, and not working for what you're looking at so far but also creating other records / associations that you don't actually want.
# Jun 14th 2021, 19:28 tomrwaller So a follow-up then if you don't mind... Is this the best way to do this? I mean it works right :) but I wonder if I'm doing something I shouldn't be.
# Jun 14th 2021, 19:27 greg138 Look at your entity after patching, you may have a `baselines` array in there with stuff you don't really want?
# Jun 14th 2021, 19:27 tomrwaller Aha - thank you both :) ['baselines']['_ids'] does indeed work! I think this is acceptable to me - I only want to create answer records, not baselines. Baselines simply contain a whole bunch of recommendations. I need an answer for every recommendation across whatever baselines a user has selected.
# Jun 14th 2021, 19:26 greg138 It could cover every use case, but then it would still be on beta version 0.9.12796.
# Jun 14th 2021, 19:25 kevin.pfeifer but why though /s :,)
# Jun 14th 2021, 19:25 greg138 Cake can't possibly do *everything* out of the box, there's always going to be some custom coding required.
# Jun 14th 2021, 19:23 greg138 Before changing to this, you should very much be aware of exactly what `_ids` is doing, in terms of records being created in the database. It looks to me like what you get if you do that might not be at all what you want. In which case using your custom field name could be the right way to go, and all you need to do is manually specify the label for the input field.
# Jun 14th 2021, 19:22 kevin.pfeifer indeed
# Jun 14th 2021, 19:22 greg138 So, `$data['baselines._ids']` would indeed be blank, but `$data['baselines']['_ids']` would not be.
# Jun 14th 2021, 19:21 kevin.pfeifer I am on Cake 4.2.6
# Jun 14th 2021, 19:20 kevin.pfeifer @tomrwaller I just checked a basic beforeMarshal method inside one of my models where i use a `projects._ids` field and i do indeed have the data in there (had to `pr(); die();` it because for some reason xdebug doesn’t show it correctly :shrug:)
# Jun 14th 2021, 19:18 jh Yes I can read the migration guides, I am asking about experiences here
# Jun 14th 2021, 19:17 jh any rather big changes from say 3.8 to 4.2?
# Jun 14th 2021, 19:09 tomrwaller In my case, I'm not actually using customers, that was an example. With this, when I save an assessment, an answer gets created for each recommendation in the selected baselines. When I change the form control back to baselines._ids which is what it was when baked, and update the beforeMarshal to match, the if always fails because the data is empty.
# Jun 14th 2021, 19:07 tomrwaller Possibly an issue in my beforeMarshal, but it seems to work. This is what I have that works: `echo $this->Form->control('baselines_ids', ['multiple' => 'checkbox', 'disabled' => false, 'options' => $baselines]` `public function beforeMarshal(\Cake\Event\Event $event, \ArrayObject $data, \ArrayObject $options)`     `{`         `if (!empty($data['baselines_ids'])) {`            
# Jun 14th 2021, 19:07 slackebot `$recommendations = TableRegistry::getTableLocator()->get('Admin.Recommendations');`             `$query = $recommendations->find('all');`             `$query->matching('Baselines', function ($q) use ($data){`                 `return $q->where(['Baselines.id IN' => $data['baselines_ids']]);`             `});` `            `             `foreach
# Jun 14th 2021, 19:07 slackebot ($query as $count => $recommendation) {`                 `$data['answers'][$count]['applicable'] = 1;`
# Jun 14th 2021, 19:04 kevin.pfeifer there is some logic present int https://github.com/cakephp/cakephp/blob/76babd83538e3e247d1189c2289b2f7b31c2bc9a/src/View/Form/EntityContext.php#L260 and https://github.com/cakephp/cakephp/blob/fe6fd198e33f69c1d36d5df4ac2c92d26ffa4807/src/View/Helper/FormHelper.php which checks if the fieldname ends with `._ids` (one time actually checking for the ._ids and the other exploding the field by .)
# Jun 14th 2021, 19:03 greg138 Sounds like your beforeMarshal function has an issue.
# Jun 14th 2021, 19:03 greg138 Then the difference is that Cake has logic to handle a `_ids` as a special case, but nothing for `customers_ids`.
# Jun 14th 2021, 19:02 tomrwaller No. No field matching that.
# Jun 14th 2021, 19:02 greg138 Do you actually have a field in your database somewhere called `customers_ids`?
# Jun 14th 2021, 19:01 tomrwaller Yes - I'm just trying to understand what the difference is and why one works and one doesn't.
# Jun 14th 2021, 19:00 kevin.pfeifer you mean `customers._ids` right?
# Jun 14th 2021, 18:57 tomrwaller I also notice that if I change the control to control('customers_ids') I have to add a label manually, it doesn't automatically use the label as it does when using ._ids.
# Jun 14th 2021, 18:56 tomrwaller Guys - silly question - but what's the difference between customers_ids and customers_.ids? I'm calling a control in a form by control('customers._ids') and that works just fine. However, I'm using beforeMarshal to create some additional entities and I have a query there that looks for $data['customers_ids'). That works if I change the control to control('customers_ids') but it doesn't work if I leave the control as is.
# Jun 14th 2021, 17:37 kevin.pfeifer have you tried that? https://stackoverflow.com/questions/40609304/cakephp-3-x-optional-language-routing
# Jun 14th 2021, 17:33 alamnaryab `debug($this->request);` at localhost/project/en
# Jun 14th 2021, 17:32 alamnaryab I also debugged `$this->request` it is not showing language parameter while I have written code to get language parameter from `request->params` and switch accordingly
# Jun 14th 2021, 17:28 alamnaryab as now `language` is no more any parameter
# Jun 14th 2021, 17:27 alamnaryab @admad I added separate route scopes for both languages but before when I was switching language I used below line but now it is not working asdsa
# Jun 14th 2021, 17:03 alamnaryab better if it can force default language = ar if no lange parameter forun in url
# Jun 14th 2021, 17:02 alamnaryab @admad below is my routes file before Multilanguage, now I have 2 languages , can you plz convert this to for languages (en,ar) ```use Cake\Routing\Route\DashedRoute; use Cake\Routing\RouteBuilder; use Cake\Routing\RouterBuilder; $routes->setRouteClass(DashedRoute::class); $routes->scope('/', function (RouteBuilder $builder) { $builder->connect('/', ['controller' => 'cv', 'action' => 'index']);
# Jun 14th 2021, 17:02 slackebot $builder->fallbacks(); }); $routes->prefix('Admin', function (RouteBuilder $routes) { $routes->connect('/', ['controller' => 'Users', 'action' => 'login']); $routes->fallbacks(DashedRoute::class); });```
# Jun 14th 2021, 16:58 alamnaryab I am attaching routes output from debugger and also cmd
# Jun 14th 2021, 16:52 kevin.pfeifer can/should we add a warning to the scope function if such a "placeholder" can be detected? :thinking_face:
# Jun 14th 2021, 16:48 admad @alamnaryab `scope(':/language')` that's your problem. Scopes can't be place holders/route elements, they need to be static strings.
# Jun 14th 2021, 16:19 kevin.pfeifer @alamnaryab I would try to check the "Routes" tab in the DebugKit to see if the routes are actually generated the way you intend them to. Otherwise you could also run `bin/cake routes` in the terminal if you don't have access to the DebugKit to see the same table of active routes. Basically (as far as I know) the route system works like • go through all the available routes • after the first match is present go to
# Jun 14th 2021, 16:19 slackebot that Controller/Action/Whatever So it could be that the routes are just being set differently than you expect. Unfortunately I can't tell you how to set your routes so you have a language prefix/scope for your controllers.
# Jun 14th 2021, 15:25 martin ok fixed it by setting it to _orginal in entity when I update 1 of the 2 fields :)
# Jun 14th 2021, 15:07 martin https://github.com/cakephp/cakephp/blob/master/src/Datasource/EntityTrait.php#L304 hmm it just reads out the array from orignal, so does not work with custom made fields :(
# Jun 14th 2021, 15:03 martin Hmm when you create a virtual field inside a entity. it does not work with getOriginal(‘virtualfieldname’) ? because that already returns the new name (virtuel field just combines 2 fields)
# Jun 14th 2021, 13:55 a.vanniel I just don't know enough about routing to be able to help you here.. maybe someone else has an idea?
# Jun 14th 2021, 13:55 a.vanniel is placing the language as the first parameter actually possible with Cake? I am not entirely sure, it does feel like it get's a bit complicated because of this and I am not sure if Cake actually enjoys this way of routing/handling urls... whenever I needed to switch from locale I would add a request variable named lang= of language= but that might not be suitable for you... it might also not be very elegant.
# Jun 14th 2021, 12:12 alamnaryab I have cakephp4.2 project I have admin prefix I am using Authentication Plugin for admin I also have Localization that is English and Arabic Languages, it worked until the language parameter is saved in session (followed official documentation) but when I needed to show language parameters in URLs and also `$this->Html->link()` automatically add current language parameters to links I tried many things with routing, some
# Jun 14th 2021, 12:12 slackebot time getting error saying missing route, while sometime ```Warning (2): preg_match(): Compilation failed: two named subpatterns have the same name (PCRE2_DUPNAMES not set) at offset 42 [CORE\src\Routing\Route\Route.php, line 454]``` my routes are as below ```<?php use Cake\Routing\Route\DashedRoute; use Cake\Routing\RouteBuilder; $routes->setRouteClass(DashedRoute::class); $routes->scope('/:language', function (RouteBuilder
# Jun 14th 2021, 12:12 slackebot $builder) { $builder->connect('/', ['controller' => 'cv', 'action' => 'index']); $builder->connect('/:language/:controller/:action/*', array(), array('language' => 'en|ar')); $builder->connect('/:language/:controller', array('action' => 'index'), array('language' => 'en|ar')); $builder->connect('/:language', array('controller' => 'cv', 'action' => 'index'), array('language' => 'en|ar')) ;
# Jun 14th 2021, 12:12 slackebot $builder->fallbacks(); }); $routes->scope('/:language', function (RouteBuilder $routes) { $routes->prefix('Admin', function (RouteBuilder $routes) { $patterns = ['language' => 'en|ar']; $routes ->connect('/:controller/:action/*', []) ->setPatterns($patterns); $routes ->connect('/:controller', ['action' => 'index']) ->setPatterns($patterns);
# Jun 14th 2021, 12:12 slackebot $routes ->connect('/', ['controller' => 'Users', 'action' => 'login']) ->setPatterns($patterns); $routes->fallbacks(DashedRoute::class); }); }); $routes->scope('/', function (RouteBuilder $builder) { $builder->connect('/*', ['controller' => 'cv', 'action' => 'index','language'=>'ar'], array('language' => 'en|ar')); $builder->fallbacks(); }); ``` I have no idea what is right
# Jun 14th 2021, 12:12 slackebot way to debug, currently just hit and try. please help me out in this issue I will also be able to give anydesk access to quickly debug and trace the issue.
# Jun 14th 2021, 12:02 alamnaryab ok let me write again with more description
# Jun 14th 2021, 11:56 a.vanniel I fear that is because it is not clear what your question is... or at least I did not even see anything remotely like a question until i clicked on the reply of your own message.
# Jun 14th 2021, 11:45 alamnaryab :white_frowning_face: no one is helping me
# Jun 14th 2021, 11:43 alamnaryab tried many things some time getting missing route some time some other error
# Jun 14th 2021, 11:41 dantedantas Thanks @kevin.pfeifer. I am new to CakePHP and I didn't have time to improve my knowledge with CakePHP. I will give it a try. If I will have questions, I will come back here to "bother" you. :) Vielen Dank!