Log message #4227672

# At Username Text
# Feb 18th 2020, 19:57 ndm Actually the `provider` option and `setProvider()` go hand in hand, I mixed something up there
# Feb 18th 2020, 19:54 ndm https://book.cakephp.org/4/en/core-libraries/validation.html#using-custom-validation-rules https://book.cakephp.org/4/en/core-libraries/validation.html#adding-validation-providers
# Feb 18th 2020, 19:54 ndm Also you can use custom validation providers, either per rule using the `provider` option, or per validator by setting it via `Validator::setProvider()`
# Feb 18th 2020, 19:53 ndm More like `$validator->add('password', ['rule' => [$this, '_isPasswordValue']]);`, assuming it's a method on the containing object. The `rule` option generally accepts callables, ie also closures.
# Feb 18th 2020, 19:47 wizardfix (v. 3.8) I'm trying to set up password validation. I have written a function, `_isPasswordValid()`, that tests if a password is valid according to character requirements, so I need to make a rule that my validator calls this function. How do I do this? Something like `$validator->add('_isPasswordValid', ['field' => 'password']);` ? :thinking_face:
# Feb 18th 2020, 19:39 ndm no problem
# Feb 18th 2020, 19:33 FunkadelicRelic Got it! Thank you @ndm - again....
# Feb 18th 2020, 19:24 ndm If you're using the form helper, then you need to make sure that the option for the control is a `key => value` array, where the `key` is the value that you want to be passed, the `value` is the label that you want to display.
# Feb 18th 2020, 19:16 FunkadelicRelic I think $data['recommendationgroup_id'] may be coming in wrong from the dropdown in my add form. Thinking maybe I'm pulling in 0 instead of 1 for the first dropdown item.
# Feb 18th 2020, 19:13 ndm If the number would be used at all, and not just interpreted as array index
# Feb 18th 2020, 19:12 ndm Not sure what exactly you mean by "_backwards results_", if it's sorting, then you need to order accordingly, as the default order of the DBMS can be rather non-deterministic. Have the condition the other way around however certainly shouldn't work at all, as it would compare a integer against a string, like `WHERE 1 = 'recommendation_group_id'`.
# Feb 18th 2020, 19:08 FunkadelicRelic One interesting thing is that if I flip the where as mentioned, I seem to get backwards results, but that could just be my statement, I'll have a quick look.
# Feb 18th 2020, 19:07 FunkadelicRelic Well that certainly looks better!
# Feb 18th 2020, 19:03 FunkadelicRelic Ah good catch - I was still on toArray. I'll try now.
# Feb 18th 2020, 19:01 ndm btw your `where()` array should be flipped, it should be like `where(['recommendation_group_id' => $data['recommendationgroup_id'])`
# Feb 18th 2020, 19:00 challgren https://cakesf.herokuapp.com/ is the link to get an invite
# Feb 18th 2020, 19:00 ndm Have you changed from using `all()`?
# Feb 18th 2020, 18:58 FunkadelicRelic Slack sounds like a great idea! I get a new error on that line now @ndm. Call to a member function extract() on array
# Feb 18th 2020, 18:54 ndm `all()` will return a result set, which implements the collection interface. Try `$data['recommendations']['_ids'] = $query->extract('id')->toArray();`.
# Feb 18th 2020, 18:54 ndm Not sure how a quote translate to IRC, so here it is again just in case
# Feb 18th 2020, 18:52 slackebot <ndm>
# Feb 18th 2020, 18:52 ndm If you'd use slack you'd see the missed messages :)
# Feb 18th 2020, 18:51 FunkadelicRelic So it looks like it is trying to convert array to int which is failing.
# Feb 18th 2020, 18:50 FunkadelicRelic Whoops - disconnected.
# Feb 18th 2020, 18:47 ndm `all()` will return a result set, which implements the collection interface. Try `$data['recommendations']['_ids'] = $query->extract('id')->toArray();`.
# Feb 18th 2020, 18:44 ricksaccous Oh
# Feb 18th 2020, 18:43 FunkadelicRelic .
# Feb 18th 2020, 18:43 FunkadelicRelic to integer
# Feb 18th 2020, 18:43 FunkadelicRelic array
# Feb 18th 2020, 18:43 FunkadelicRelic If I just do $query, I then get Cannot convert value of type
# Feb 18th 2020, 18:39 FunkadelicRelic Sorry, I don't really understand. I don't recall deliberately writing to session anywhere. If I do $data['recommendations']['_ids'] = [1, 2]; then it saves perfectly so I guess it's something in the block of code I pasted above?
# Feb 18th 2020, 18:38 ricksaccous check it in debug
# Feb 18th 2020, 18:38 ricksaccous if all ur selecting is id, I think...
# Feb 18th 2020, 18:37 ricksaccous also you wouldn't need to do $query['id'] you'd just do $query
# Feb 18th 2020, 18:37 ricksaccous where are you writing to session?
# Feb 18th 2020, 18:35 FunkadelicRelic Thanks @ricksaccous - if I swap that out I get the following error: Argument 1 passed to Cake\Http\Session::_overwrite() must be of the type array, null given, called in /var/www/html/csa-portal-3/vendor/cakephp/cakephp/src/Http/Session.php on line 491
# Feb 18th 2020, 18:33 ricksaccous do toArray();
# Feb 18th 2020, 18:33 ricksaccous instead of ->all();
# Feb 18th 2020, 18:33 ricksaccous by default a query returns a query object
# Feb 18th 2020, 18:29 FunkadelicRelic If I replace the last bit with a manual array of values instead of $query['id'] such as [1, 2] it works perfectly.
# Feb 18th 2020, 18:28 FunkadelicRelic When I do the debug, I'm getting the correct recommendations, it's just the last line I think I may be doing wrong.