# |
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 |