Logs for #cakephp

Page 13 of 36,922, showing 100 records out of 3,692,143 total, starting on record 1,201, ending on 1,300

# At Username Text
# Jul 12th 2021, 16:00 tyler.adam.lazenby the escape and escapeTitle options are not working
# Jul 12th 2021, 16:00 tyler.adam.lazenby I would like to report a bug on the submit element on the Form helper
# Jul 12th 2021, 15:44 japerlman @ndm Thank you!
# Jul 12th 2021, 15:33 richard question not necessarily related to cake but will ask here for now in case someone happens to know, I have a sneaking suspicion that a cake app i put together is getting a lot of mysql requests during peak times, causing a lull in the mysql process, what is the best way to record/verify this and what is the best solution for this?
# Jul 12th 2021, 15:33 ndm @paolo.bragagni Why don't you iterate `associations`, which already has the keys that denote the type of association?
# Jul 12th 2021, 15:32 ndm @japerlman There's still a component that you can use for retrieving user data: `$this->Authentication->getIdentity()->get('user_id');` This is preferred over accessing the possible storage like the session, as it keeps your code separate from the used authentication method. https://book.cakephp.org/authentication/2/en/authentication-component.html https://book.cakephp.org/authentication/2/en/migration-from-the-authcomponent.html
# Jul 12th 2021, 15:06 japerlman if I look at just getRequest() it's there, just a matter of reading it properly, awesome, thanks for the help!
# Jul 12th 2021, 15:05 japerlman odd, it's like I don't have a session?
# Jul 12th 2021, 15:04 japerlman Call to a member function read() on null
# Jul 12th 2021, 14:40 conehead @japerlman try if you can get it via $this->getRequest()->getSession->read();
# Jul 12th 2021, 14:32 japerlman sorry that phrasing was awful, I just want to know how to read the user_id of the logged in user
# Jul 12th 2021, 14:32 japerlman Can anyone please tell me what is the new authentication middleware version of the old auth component of, not finding it on google somehow ```$uid = $this->Auth->User('user_id');```
# Jul 12th 2021, 10:59 paolo.bragagni in loop I'fd like to check if relation is HM or is BTM
# Jul 12th 2021, 10:59 paolo.bragagni no
# Jul 12th 2021, 10:55 paolo.bragagni ??
# Jul 12th 2021, 10:55 paolo.bragagni {% set myArray =myArray |merge({"HasMany":associations.HasMany}) %} {% set myArray =myArray |merge({"BelongsToMany":associations.BelongsToMany}) %}
# Jul 12th 2021, 10:40 paolo.bragagni how to insert in relation another field?
# Jul 12th 2021, 10:40 paolo.bragagni I'd like to discern if the association is HM or BTM in relations
# Jul 12th 2021, 10:38 paolo.bragagni {% set relations = associations.BelongsToMany|merge(associations.HasMany) %}
# Jul 12th 2021, 10:38 paolo.bragagni in twig I'd like to rewrite this
# Jul 12th 2021, 09:41 conehead Was debugging an array (Session), but when trying to access a specific key it said "not found" one line later
# Jul 12th 2021, 09:31 kevin.pfeifer browser extensions are the devil
# Jul 12th 2021, 09:27 conehead What the hell...thought I was going crazy.... Any german here using the browser plugin: "binnen i be gone"? Absolutely NOT compatible with coding/debugging smaller things
# Jul 12th 2021, 09:18 dereuromark Well, one could always look into CRUD plugin :) As that is designed to do those things more dynamically.
# Jul 12th 2021, 09:15 conehead Let's say, it cannot guess dynamically. Probably it could but that would cause a pain in the ass everytime you want to change tiny things. It is something completely different to generate fields that are declared in a table/model than to load data from the database in the background. Additionally that would totally not fit into MVC pattern
# Jul 12th 2021, 08:42 dereuromark If u bake your Code yes, it will add the needed calls to Controller. It does not work magically :)
# Jul 12th 2021, 07:04 mehov Also, Cake does have `allControls()`, which is the same "guess" concept
# Jul 12th 2021, 07:02 mehov let me try your advice though. thank you!
# Jul 12th 2021, 07:02 mehov yep, manually is how I've been doing this all this time :D
# Jul 12th 2021, 07:02 mehov Since Cake is *convention over configuration*, I actually thought it will "guess", because I did my job following the conventions and declaring the association, so it kind of makes sense for Cake to understand that I want a select box full of Authors and therefore populate them
# Jul 12th 2021, 07:01 conehead manually
# Jul 12th 2021, 07:01 conehead but you could try `echo $this->Form->control('author.id', ['options' => $authors]);`
# Jul 12th 2021, 07:00 conehead yes, it should look it up automatically then if everything is named correctly
# Jul 12th 2021, 07:00 conehead Cake cannot "guess" which data is all required for the form. Especially it does not know it yet in the controller. Controller passes the data to the form.
# Jul 12th 2021, 07:00 mehov Aha, and what should the corresponding Form control look like? Is it going to pick `$authors` up automatically?
# Jul 12th 2021, 06:58 conehead $this->set('authors', $this->Articles->Authors->find('list'));
# Jul 12th 2021, 06:57 mehov I guess I didn't. The CakeBook section I linked to says nothing about that, so I thought it'd load the necessary list 'automagically'. Did I get it wrong? If so, how do I add the required data in controller?
# Jul 12th 2021, 06:55 conehead @mehov Did you add the required data in the controller?
# Jul 12th 2021, 06:51 slackebot2 input with the current `author_id` value. - I have also tried `$this->Form->allControls()`, but the select box it creates is empty Am I missing something obvious? Or do I still have to manually retrieve a list of all authors and pass it to the form control? I thought it was supposed to do that for me automatically?
# Jul 12th 2021, 06:51 mehov Hi everyone, I have configured Article belongsTo Author. I confirmed it works by calling `$this->Article->get()` with a contain for the Author. I'm looking for an easy way to populate a select box with available authors inside the Article form. - Following https://book.cakephp.org/3/en/views/helpers/form.html#creating-inputs-for-associated-data, I have tried `echo $this->Form->control('author.id');`, but that creates a hidden
# Jul 12th 2021, 05:44 conehead nitish you should check your database. cake usually creates the validation based on the database. If I remember correctly, "notEmptString" is only added, if the field may not be null. In this case it should be not that much of a problem, but something you should check in general
# Jul 12th 2021, 05:01 nitish got it. I'd to change 'notEmptyString' to 'allowEmptyString'
# Jul 12th 2021, 04:53 nitish Hello all. I am new to cakephp. I've created a form using 'cake bake all'. How can I remove a required fied from form?
# Jul 9th 2021, 17:11 kevin.pfeifer
# Jul 9th 2021, 17:11 kevin.pfeifer I would say this was partially already answered yesterday :)
# Jul 9th 2021, 16:54 devito hello all, does anyone know if i can use the fields mysql function in the cake3.x order clause?
# Jul 9th 2021, 14:08 cnizzardini good point
# Jul 9th 2021, 13:32 kevin.pfeifer I am not aware that default twig allows xdebug breakpoints. You would have to create a custom twig function (something like `{{ breakpoint() }}` ) which then will call a function wich contains a `xdebug_break()`
# Jul 9th 2021, 13:27 cnizzardini have you tried xdebug?
# Jul 9th 2021, 13:21 cnizzardini IDK if I did this very well since its for a rudimentary demo, but poke around this: https://github.com/mixerapi/demo/blob/main/app/plugins/AdminApi/src/Plugin.php
# Jul 9th 2021, 13:19 cnizzardini do you have the middleware loaded?
# Jul 9th 2021, 12:12 paolo.bragagni ok See it
# Jul 9th 2021, 12:10 paolo.bragagni how does {{ dump() }} works?
# Jul 9th 2021, 10:40 kevin.pfeifer so e.g. your default apache vhost points to `/var/www/html` but it should be `/var/www/html/appname/webroot`
# Jul 9th 2021, 10:38 kevin.pfeifer What you are looking for are called "virtual hosts" (short vhost) and is a feature your webserver should support (not cakephp) For apache 2.4 see https://httpd.apache.org/docs/2.4/vhosts/examples.html For nginx see https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-16-04
# Jul 9th 2021, 09:40 rrd564 Hehe, this channel is so super. Most of the time I post here after spending 45 minutes with no luck, I post here and found the solution in 2 minutes :)
# Jul 9th 2021, 09:38 rrd564 Hi, I try to use token authentication with cakephp/authentication. I send the appropritae header, authenticator is loaded, still in doIdentityCheck() the request identity attribute is null. What do I miss?
# Jul 9th 2021, 09:31 nayakvradhit Can anyone please tell currently I am accessing the cakephp app @ipaddress/appname/index.php but I want to access at ipaddress/ how can we achieve?
# Jul 9th 2021, 07:41 kevin.pfeifer for me the easiest was to use `{{ dump() }}` sure you only see the debug output in the generated php file but getting xdebug to work in twig is a bit more complicated
# Jul 9th 2021, 06:50 paolo.bragagni hi how to debug variable in twig (while baking?)
# Jul 8th 2021, 17:15 tyler.adam.lazenby scratch that I made the type text/plain
# Jul 8th 2021, 17:14 tyler.adam.lazenby My hello world for a new action lol ```public function addUser() { /** @var \Authentication\IdentityInterface|\App\Model\Entity\User $user */ $user = $this->Authentication->getIdentity(); $this->Authorization->authorize($user->account, 'addUser'); return $this->response->withType('application/json') ->withDisabledCache() ->withStringBody('Hello World'); }```
# Jul 8th 2021, 14:54 tyler.adam.lazenby I will do that, thanks!
# Jul 8th 2021, 14:53 dereuromark for me entities are ORM (and table) related. sounds more like generic DTOs what you are looking for, see the plugin for it maybe (or create/generate custom hardcoded ones).
# Jul 8th 2021, 14:52 tyler.adam.lazenby On a related question... is it a good idea to create entities that aren't supported by a table? What I mean is for example a call using a specific format for an API call.
# Jul 8th 2021, 14:51 tyler.adam.lazenby oh I like that! (replying to Kevin Pfeifer's comment about mass assignment)
# Jul 8th 2021, 14:21 ndm @k4t Yes... just try it
# Jul 8th 2021, 14:18 steinkel awesome!
# Jul 8th 2021, 14:10 ndm If you don't need automatic identifier quoting or expression parsing capability, pass the SQL snippet as a single string value: `'(IFNULL(previous_price, price) / price) DESC'`. `orderDesc()` accepts raw SQL too: ```$this->Product ->find() ->orderDesc('IFNULL(previous_price, price) / price')```
# Jul 8th 2021, 14:04 ewbarnard Thank you, Jorge! My new co-worker Gary Cartagena will be attending. He and I will be building CakePHP 4.x together.
# Jul 8th 2021, 14:02 steinkel London tz will be, in ~1h
# Jul 8th 2021, 13:50 kupe3b hi, with ```$products=$this->Product->find('all',array( 'order'=>array('IFNULL(previous_price,price)/price'=>'DESC') ));``` in the generated SQL i get : ```ORDER BY `IFNULL(previous_price,price)/price` DESC``` how can i order by this little more complex expression? putting quotes around `IFNULL(previous_price,price)/price` generates broken sql
# Jul 8th 2021, 13:30 danco.zvezdakoski please ignore my messages.. i just got response on the email i sent few minutes ago to the official email.
# Jul 8th 2021, 13:29 danco.zvezdakoski i should be in the list and should have an email with the session login details, but so far i have nothing in the mailbox. Dont want to miss it...
# Jul 8th 2021, 13:26 danco.zvezdakoski regarding the upcoming cakephp training session which should happen in 90 minutes... Anyone of the organisers present here?
# Jul 8th 2021, 13:25 danco.zvezdakoski hello
# Jul 8th 2021, 13:24 k4t Do CAkePHP HTML Form helper escapes input attributes like value?
# Jul 8th 2021, 13:24 k4t Hello
# Jul 8th 2021, 13:17 ewbarnard @steinkel Time zones are hard. Today's training is marked as both GMT and Western European Time, but I think Western European summer time is GMT+1. Is the training time zone currently at 13:16 with training starting at 16:00?
# Jul 8th 2021, 12:01 paolo.bragagni :)
# Jul 8th 2021, 12:00 paolo.bragagni it works
# Jul 8th 2021, 12:00 ndm If your bootstrap is invoked when baking, sure.
# Jul 8th 2021, 11:58 paolo.bragagni it gets inflector rules from bootstrap.php?
# Jul 8th 2021, 11:55 ndm But maybe you should it make it view variable instead, like your other variables.
# Jul 8th 2021, 11:54 ndm The CakePHP twig view has filters for inflection (https://github.com/cakephp/twig-view#extension-filters), so you could do something like `{{ variableName|singularize|underscore }}_id`.
# Jul 8th 2021, 11:49 paolo.bragagni (while baking?)
# Jul 8th 2021, 11:48 paolo.bragagni how to use it in twig?
# Jul 8th 2021, 11:48 paolo.bragagni BUT
# Jul 8th 2021, 11:48 paolo.bragagni Inflector::rules('irregular', ['lingua' => 'lingue']);
# Jul 8th 2021, 11:48 paolo.bragagni well
# Jul 8th 2021, 11:48 paolo.bragagni I use inflectr and it works quite wenn
# Jul 8th 2021, 11:44 ndm There is always a way for anything, it's just a matter of what lengths one is willing to go to. You get those names either through inflection (https://github.com/cakephp/cakephp/blob/4.2.7/src/Core/ConventionsTrait.php#L48-L61 - the inflector only speaks US english, one can add custom inflections if one wanted to, but it's of course way easier to simply stick to english), or by inspecting possible association configuration.
# Jul 8th 2021, 11:17 paolo.bragagni language_id from Languages?
# Jul 8th 2021, 11:17 paolo.bragagni so no way to get lingua_id from Lingue?
# Jul 8th 2021, 11:12 paolo.bragagni :(
# Jul 8th 2021, 10:55 slackebot2 !dereuromark-advice
# Jul 8th 2021, 10:55 slackebot2 Command sent from Slack by dereuromark:
# Jul 8th 2021, 10:51 paolo.bragagni but I dont find the way to get the 'lingua_id'
# Jul 8th 2021, 10:51 paolo.bragagni ${{ otherPlural }} = $this-{{ currentModelName }}->{{ otherName }}->find('list',['conditions' => ['id' => ${{ singularName }}->lingua_id]]);
# Jul 8th 2021, 10:51 paolo.bragagni more or less is: