# |
Sep 4th 2019, 13:58 |
ricksaccous |
I think that's how it works anyway |
# |
Sep 4th 2019, 13:57 |
ricksaccous |
just to forego that error message |
# |
Sep 4th 2019, 13:57 |
ricksaccous |
so maybe you want to do allowEmptyString('whatever', true) |
# |
Sep 4th 2019, 13:57 |
ricksaccous |
once you plop a rule on a field it's deemed not allowed to be empty |
# |
Sep 4th 2019, 13:57 |
ricksaccous |
that's why you're getting that weird error message |
# |
Sep 4th 2019, 13:57 |
ricksaccous |
usually the notEmpty rule is automatically applied unless you turn it off and that's the error message that pops up |
# |
Sep 4th 2019, 13:57 |
davorminchorov |
@ricksaccous nope |
# |
Sep 4th 2019, 13:56 |
jotpe |
and without the namespace? |
# |
Sep 4th 2019, 13:56 |
ricksaccous |
@davorminchorov did you specify allowEmptyString? |
# |
Sep 4th 2019, 13:56 |
dereuromark |
class name? basic php get_class() I would think |
# |
Sep 4th 2019, 13:55 |
jotpe |
For Tables I can use ->alias(); |
# |
Sep 4th 2019, 13:55 |
jotpe |
Hey! What's the way of getting the classname of an Entity when I have the object? |
# |
Sep 4th 2019, 13:52 |
davorminchorov |
notBlank for other fields I mean, not the one in the add() method specifically |
# |
Sep 4th 2019, 13:52 |
neon1024 |
Probably don’t want notBlank then I suppose |
# |
Sep 4th 2019, 13:51 |
slackebot |
<neon1024> |
# |
Sep 4th 2019, 13:51 |
davorminchorov |
Thanks! |
# |
Sep 4th 2019, 13:51 |
davorminchorov |
it's a string 0 :) |
# |
Sep 4th 2019, 13:50 |
neon1024 |
Good luck :thumbsup: |
# |
Sep 4th 2019, 13:50 |
neon1024 |
That’s me out of ideas :slightly_smiling_face: |
# |
Sep 4th 2019, 13:50 |
davorminchorov |
in the same table class |
# |
Sep 4th 2019, 13:50 |
davorminchorov |
I have a notBlank rule before that one |
# |
Sep 4th 2019, 13:50 |
neon1024 |
Maybe you’ve put the rule in the wrong table class? |
# |
Sep 4th 2019, 13:50 |
neon1024 |
Perhaps I can set manager_not_required to 0 so PHP thinks it’s empty and also empty manager_id |
# |
Sep 4th 2019, 13:49 |
neon1024 |
Do you have a `last` option on another rule, perhaps you’re failing an earlier validation rule and it never reaches this rule |
# |
Sep 4th 2019, 13:48 |
davorminchorov |
no, that's an ID value but it should be required if the manager_not_required is 0 |
# |
Sep 4th 2019, 13:48 |
neon1024 |
Sounds more like a foreign key to me |
# |
Sep 4th 2019, 13:48 |
neon1024 |
So a boolean for `assignment_manager_id` ? |
# |
Sep 4th 2019, 13:47 |
davorminchorov |
the data is there |
# |
Sep 4th 2019, 13:47 |
davorminchorov |
it's a select dropdown with 0 and 1 values |
# |
Sep 4th 2019, 13:47 |
neon1024 |
Probably worth ensuring that the data exists in the request data would be my first stop |
# |
Sep 4th 2019, 13:46 |
neon1024 |
Unless of course it’s a checkbox and you happen to have `hiddenField => false` in your options, perhaps the request data never contains the field to validate |
# |
Sep 4th 2019, 13:46 |
davorminchorov |
I do have but not on the same model |
# |
Sep 4th 2019, 13:45 |
neon1024 |
I see it’s a double conditional! |
# |
Sep 4th 2019, 13:45 |
neon1024 |
You could just `return !$managerNotRequired` surely? |
# |
Sep 4th 2019, 13:44 |
neon1024 |
When you’re casting it to int above |
# |
Sep 4th 2019, 13:44 |
neon1024 |
Plus this seems very odd `return ! $managerNotRequired ? (bool) $value : true;` |
# |
Sep 4th 2019, 13:44 |
neon1024 |
Do you have another rule called `custom` ? |
# |
Sep 4th 2019, 13:33 |
slackebot |
reason the message is a generic one: `This field cannot be left empty` and the check does not seem to be triggered in the closure. Any ideas what's missing here? |
# |
Sep 4th 2019, 13:33 |
davorminchorov |
Hi! I have the following custom validation rule in my table class: ``` $validator->add('assignment_manager_id', 'custom', [ 'rule' => function ($value, $context) { $managerNotRequired = (int) $context['data']['manager_not_required']; return ! $managerNotRequired ? (bool) $value : true; }, 'message' => 'Manager selection is required', ]); ``` For some |
# |
Sep 4th 2019, 13:14 |
spriz |
We killed it after figuring out cake query distinct added `GROUP BY` :) :) |
# |
Sep 4th 2019, 11:53 |
alexdd55976 |
made my API crash after an update... took me hours to find the problem |