Log message #4045760

# At Username Text
# Jun 28th 2017, 15:04 chris-andre oh. notBlank() is the new notEmpty() :slightly_smiling_face: Good to know
# Jun 28th 2017, 15:03 jeremyharris no worries, good luck :slightly_smiling_face:
# Jun 28th 2017, 15:03 chris-andre Thanks anyway @jeremyharris .
# Jun 28th 2017, 15:01 chris-andre That did not work. I need to do some other magic :P
# Jun 28th 2017, 14:57 chris-andre That is just a quick test away from the answer. Ill test.
# Jun 28th 2017, 14:56 chris-andre Allright, so if requirePresence fails, but the next rule is true, the property will go trough the validation?
# Jun 28th 2017, 14:53 jeremyharris at least one of them must be posted though
# Jun 28th 2017, 14:52 jeremyharris use requirePresence if you want it to fail if no property is posted. then if it is, it will continue down the list of rules for that key
# 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