# |
May 27th 2016, 16:29 |
nemmons |
ah. |
# |
May 27th 2016, 16:28 |
ypnos |
read the first sentence here http://book.cakephp.org/3.0/en/orm/validation.html#applying-application-rules |
# |
May 27th 2016, 16:28 |
ypnos |
no during save only rules are checked |
# |
May 27th 2016, 16:27 |
nemmons |
actually, maybe my statement above was wrong. since validator() returns the model's default validator, i'm then attaching a new validation to the default validator. i think that would be triggered by a save |
# |
May 27th 2016, 16:27 |
ypnos |
let me see maybe I can also learn something new |
# |
May 27th 2016, 16:27 |
nemmons |
http://book.cakephp.org/3.0/en/orm/validation.html#validating-data-before-building-entities i mean |
# |
May 27th 2016, 16:27 |
nemmons |
@ypnos thanks but i think that might be contradicted by http://book.cakephp.org/3.0/en/orm/validation.html |
# |
May 27th 2016, 16:27 |
ypnos |
if you use patchEntity or pass data in newEntity, default validation should run |
# |
May 27th 2016, 16:26 |
ypnos |
nemmons validation takes place during mass-assignment. if you create an empty Entity and then fill some values by-hand it will never kick in (afaik) |
# |
May 27th 2016, 16:25 |
nemmons |
if, in a controller, i call `'$this->Table->validator()->notEmpty('some_field');` and then attempt to create and save a new entity without some_field, that won't actually matter, right? because i didn't pass the name of a validator in during my newEntity() call |
# |
May 27th 2016, 16:24 |
nemmons |
just to make sure i understand validation in 3.x |
# |
May 27th 2016, 16:20 |
ypnos |
lol scrap it |
# |
May 27th 2016, 16:18 |
max-86666 |
for the record, ACL are handled the same way :/ |
# |
May 27th 2016, 16:17 |
max-86666 |
at some point i really like to kill him, i have a lot of weird table in there :) |
# |
May 27th 2016, 16:16 |
ypnos |
I'd rather kill the database designer though.. don't forget that the roundtrip etc. you are imposing through this is a real performance killer |
# |
May 27th 2016, 16:15 |
max-86666 |
thx ypnos, that seems perfect |
# |
May 27th 2016, 16:15 |
ypnos |
In my case I do this for Entities created from a Form that lack the contains because the foreign keys were patched-in after creating the entity |
# |
May 27th 2016, 16:14 |
ypnos |
max-86666: you could rewrite the loadContain method to do the fetch |
# |
May 27th 2016, 16:13 |
ypnos |
max-86666: this is some code I am having https://gist.github.com/ypnos-web/f2aeb3d7744585fa33c78a1edcb60007 |
# |
May 27th 2016, 16:13 |
styks1987 |
ajaxLogin needs to be a string? The docs are unclear on how to use isAuthorized with ajax requests that need to respond with 403 instead of the redirect |
# |
May 27th 2016, 16:11 |
max-86666 |
i'll try the lsazy load from Entity, thx ypnos |
# |
May 27th 2016, 16:11 |
sab-cakefest |
ACTION *brainmelt* |
# |
May 27th 2016, 16:11 |
max-86666 |
oh afterfind removed in cake 3 ^^ |
# |
May 27th 2016, 16:10 |
ypnos |
I would still not do this |
# |
May 27th 2016, 16:10 |
ypnos |
max-86666: you can also lazy load an association in the Entity on access. so at that point the Entity could parse its field containing the list to fetch the real objects |
# |
May 27th 2016, 16:09 |
max-86666 |
suere, i think i'll use afterfind to parse that comma separated list |
# |
May 27th 2016, 16:08 |
styks1987 |
the default looks like a redirect but I want a 401 response |
# |
May 27th 2016, 16:08 |
nemmons |
so less magic |
# |
May 27th 2016, 16:08 |
nemmons |
you could, of course, still use cake for this. just not a cake association. |
# |
May 27th 2016, 16:08 |
styks1987 |
where should I define a custom not authorized request for ajax authorization? |
# |
May 27th 2016, 16:07 |
ypnos |
but can't :/ |
# |
May 27th 2016, 16:07 |
ypnos |
yeah would love to make it easier for you |
# |
May 27th 2016, 16:07 |
max-86666 |
i thought the same, but wanted to be sure :) |
# |
May 27th 2016, 16:07 |
nemmons |
sorry =( |
# |
May 27th 2016, 16:07 |
max-86666 |
well, thx for your advices :) |
# |
May 27th 2016, 16:07 |
ypnos |
manifesting your bullshit db in fresh code is IMHO the worst you can do |
# |
May 27th 2016, 16:06 |
ypnos |
but it will become a real performance problem |
# |
May 27th 2016, 16:06 |
max-86666 |
but i can't :/ |
# |
May 27th 2016, 16:06 |
ypnos |
and if you can't, maybe you can use SQL functions to build a VIEW that is usable |
# |
May 27th 2016, 16:06 |
max-86666 |
can't agreee more |
# |
May 27th 2016, 16:06 |
nemmons |
max-86666 sorry but i think what you're trying to do is probably too weird for Cake's ORM |