# |
Oct 6th 2016, 18:11 |
birdy247 |
I baked a form |
# |
Oct 6th 2016, 18:05 |
CoderJon |
Thanks for the direction! Found it in http://book.cakephp.org/3.0/en/orm/entities.html#validation-errors and not in the saving data section, lol |
# |
Oct 6th 2016, 18:05 |
michaelze |
CoderJon: You can also pass a field's name to the errors() method in order to retrieve specific information about only one field's error... |
# |
Oct 6th 2016, 18:05 |
nemmons |
it will be an array containing fields and error messages |
# |
Oct 6th 2016, 18:05 |
nemmons |
Yup |
# |
Oct 6th 2016, 18:04 |
CoderJon |
Ohhh, so something like $article->errors() ? It wasn't listed in the save section of the book. |
# |
Oct 6th 2016, 18:01 |
michaelze |
CoderJon: You can use the EntityTrait::errors() method on the entity that failed to save... |
# |
Oct 6th 2016, 18:00 |
escape |
CoderJon, from the entity |
# |
Oct 6th 2016, 17:59 |
CoderJon |
If your save fails in cakephp 3, how do you get the error message in the controller? |
# |
Oct 6th 2016, 17:50 |
hmic |
you can read them for every version, so 2.4, 2.5 and so on |
# |
Oct 6th 2016, 17:49 |
hmic |
http://book.cakephp.org/2.0/en/appendices/2-3-migration-guide.html |
# |
Oct 6th 2016, 17:36 |
Leidenfrost |
I couldn't find a guide to upgrade cake 2.x to a more recent version. Does it have any risk involved? |
# |
Oct 6th 2016, 17:33 |
Leidenfrost |
hmic: It worked. Thanks :) |
# |
Oct 6th 2016, 17:31 |
nemmons |
Anyway @hmic thanks very much for your help and guidance on this issue |
# |
Oct 6th 2016, 17:30 |
nemmons |
It feels kind of like 'cheating' to create a 'fake' event like that |
# |
Oct 6th 2016, 17:19 |
hmic |
just play the event again as soon as you got the information needed. neat! |
# |
Oct 6th 2016, 17:19 |
hmic |
its a solid looking solution... i do actually like it! |
# |
Oct 6th 2016, 17:17 |
nemmons |
@hmic I solved my footprint problem in what i think is a pretty gross and goofy way. I added `$this->footprint(new Event('', TableRegistry::get('Users')));` to my beforeFilter. Basically just simulating an event so that the FootprintAwareTrait can attach the FootprintListener to the UsersTable. It's not pretty but it works. |
# |
Oct 6th 2016, 17:16 |
hmic |
belongsTo Manager, set the foreignkey to manager_id, and be done. you can add the condition if you feel to, but it does not matter really |
# |
Oct 6th 2016, 17:15 |
hmic |
Leidenfrost, what i said will work on 2.2. |
# |
Oct 6th 2016, 17:15 |
hmic |
Unfaiir, http://book.cakephp.org/3.0/en/migrations.html |
# |
Oct 6th 2016, 17:14 |
hmic |
and there is no excuse eighter! |
# |
Oct 6th 2016, 17:14 |
hmic |
Leidenfrost, first: there is no reason to not upgrade this ancient version of cake to a more decent 2.x release! |
# |
Oct 6th 2016, 17:14 |
Leidenfrost |
Sorry, Cake 2.2 |
# |
Oct 6th 2016, 17:13 |
hmic |
there is a migrations shell |
# |
Oct 6th 2016, 17:13 |
hmic |
Unfaiir, there is. its callled migrations |
# |
Oct 6th 2016, 17:13 |
Unfaiir |
In cakephp 3, do we still build the tables manually or is there some kind of database migration like ASP.NET and Laravel that builds and changes the tables automatically? |
# |
Oct 6th 2016, 17:11 |
hmic |
you do need 2: belongsTo Manager and hasMany Managedusers, as nemmons said |
# |
Oct 6th 2016, 17:11 |
nemmons |
sorry ignore that |
# |
Oct 6th 2016, 17:11 |
hmic |
and it should be a belongsto as i said |
# |
Oct 6th 2016, 17:11 |
hmic |
Leidenfrost, sure you did not missmatch the foreignkey and associationforeignkeys? |
# |
Oct 6th 2016, 17:11 |
nemmons |
shouldn't that be HasMany? |
# |
Oct 6th 2016, 17:09 |
Leidenfrost |
hmic: not a good idea, but sadly I can't change the schema. I tried this: http://pastebin.com/UW5X4ELt , but it didn't work |
# |
Oct 6th 2016, 17:02 |
hmic |
the associations just need to be uniquely named. you still can name an association after the model it is in. - but as i said, not a good idea probably |
# |
Oct 6th 2016, 17:01 |
nemmons |
oh, that's good to know |
# |
Oct 6th 2016, 17:01 |
hmic |
it can actually. still its not a good idea probably ,-) |
# |
Oct 6th 2016, 17:00 |
nemmons |
@hmic can User hasMany User without having to alias it to a different name like 'ManagedUsers'? |
# |
Oct 6th 2016, 16:58 |
hmic |
leidenfrost: you will need to: belongsTo "Manager" and hasMany "User" |
# |
Oct 6th 2016, 16:57 |
nemmons |
which version of cake? |
# |
Oct 6th 2016, 16:56 |
Leidenfrost |
I'm trying to create a model relationship with itself. This is the scheme, more or less: Model 'User' has a "manager_id", which link to the column 'id' of User. That manager-type 'User' has 'manager_id' null. But I can't figure out the relationship in the cake model. |
# |
Oct 6th 2016, 16:54 |
Leidenfrost |
Hi all. I |