# |
Jun 28th 2017, 14:51 |
jeremyharris |
that is true |
# |
Jun 28th 2017, 14:51 |
chris-andre |
Yes. But it seems like the rule is not triggered if the property isn't posted. |
# |
Jun 28th 2017, 14:49 |
jeremyharris |
you’re on the right track then I think |
# |
Jun 28th 2017, 14:49 |
jeremyharris |
ah |
# |
Jun 28th 2017, 14:49 |
jeremyharris |
as an example |
# |
Jun 28th 2017, 14:49 |
chris-andre |
thats what I tried with my onOrTheOther() method. |
# |
Jun 28th 2017, 14:49 |
jeremyharris |
see: https://api.cakephp.org/3.4/source-class-Cake.Validation.Validation.html#306-323 |
# |
Jun 28th 2017, 14:48 |
jeremyharris |
you can probably make a single rule that accepts an argument for the fields to check :+1: |
# |
Jun 28th 2017, 14:48 |
chris-andre |
Yes, it is. Either a name has to be posted, or an organization number. Allright. Ill try figure it out. |
# |
Jun 28th 2017, 14:47 |
jeremyharris |
$this->request->getParam(‘prefix’) === ‘admin’ |
# |
Jun 28th 2017, 14:47 |
jarard |
what is the easiest way to check for admin prefix? |
# |
Jun 28th 2017, 14:47 |
jeremyharris |
if it’s an either-or situation |
# |
Jun 28th 2017, 14:46 |
jeremyharris |
you’ll need a rule that checks it in name as well |
# |
Jun 28th 2017, 14:46 |
jeremyharris |
you can check the “context” in that case |
# |
Jun 28th 2017, 14:46 |
chris-andre |
But damn. I will allow it empty, but either name or organization_number has to be filled. |
# |
Jun 28th 2017, 14:45 |
jeremyharris |
requirePresence would make it fail with no key defined |
# |
Jun 28th 2017, 14:45 |
jeremyharris |
bingo |
# |
Jun 28th 2017, 14:45 |
chris-andre |
Ah... There is nothing to validate! |
# |
Jun 28th 2017, 14:44 |
chris-andre |
Right. Here it is: https://gist.github.com/chris-andre/4e6d9bda6d671feb3a529654b931fe05#file-result-txt |
# |
Jun 28th 2017, 14:43 |
jeremyharris |
yeah heheh |
# |
Jun 28th 2017, 14:43 |
jeremyharris |
sorry, I meant the actual result entity |
# |
Jun 28th 2017, 14:43 |
chris-andre |
Or do you mean the object? :P |
# |
Jun 28th 2017, 14:43 |
chris-andre |
Here is entity https://gist.github.com/chris-andre/4e6d9bda6d671feb3a529654b931fe05#file-customer-php |
# |
Jun 28th 2017, 14:43 |
chris-andre |
In formhelper I use `'validate' => 'new'`, in action I use `'validator' => 'new'` |
# |
Jun 28th 2017, 14:42 |
jeremyharris |
@chris-andre can you gist the entity too? I’d like to see what data it’s getting |
# |
Jun 28th 2017, 14:42 |
jarard |
admin/Properties = index, view |
# |
Jun 28th 2017, 14:42 |
jeremyharris |
great! |
# |
Jun 28th 2017, 14:42 |
chris-andre |
https://gist.github.com/chris-andre/4e6d9bda6d671feb3a529654b931fe05#file-customerstable-php-L46 |
# |
Jun 28th 2017, 14:42 |
jarard |
it's ok I found the solution in the plugin readme :) |
# |
Jun 28th 2017, 14:41 |
jeremyharris |
right, you said “validation is triggered” I just want to make sure it’s using the proper profile |
# |
Jun 28th 2017, 14:41 |
chris-andre |
validationNew() is the validation set for new records created in CustomersController's add action. |
# |
Jun 28th 2017, 14:41 |
jeremyharris |
just a guess |
# |
Jun 28th 2017, 14:41 |
jeremyharris |
maybe Admin.Properties = index, view |
# |
Jun 28th 2017, 14:41 |
jarard |
likely it would seem |
# |
Jun 28th 2017, 14:40 |
jeremyharris |
jarard oh I don’t know tiny auth. Perhaps you need to specify rules for the admin prefix too? |
# |
Jun 28th 2017, 14:40 |
jeremyharris |
@chris-andre validationNew specifically is? |
# |
Jun 28th 2017, 14:40 |
jarard |
I am using TinyAuth and I have the line: Properties = index, view |
# |
Jun 28th 2017, 14:39 |
chris-andre |
validation is triggered, the rule method is not |
# |
Jun 28th 2017, 14:39 |
jeremyharris |
jarard I’m not seeing where it’s allowed. is it in a parent method? |
# |
Jun 28th 2017, 14:38 |
jeremyharris |
@chris-andre are you sure the method is being triggered? what’s the entity look like? |
# |
Jun 28th 2017, 14:38 |
jarard |
sure: https://gist.github.com/spacebiscuit/23245d03e1490c3e33e08981b6429e8a |