# |
Jun 30th 2017, 15:54 |
jeremyharris |
you can use what David said or http://php.net/manual/en/function.array-search.php |
# |
Jun 30th 2017, 15:53 |
alexlambson |
I might just give up and make 'role' the key and store something as the value. I'm getting hella #triggered by that numeric index |
# |
Jun 30th 2017, 15:52 |
neon1024 |
Er, values ;P |
# |
Jun 30th 2017, 15:52 |
neon1024 |
:slightly_smiling_face: |
# |
Jun 30th 2017, 15:52 |
neon1024 |
Or isset(array_keys( |
# |
Jun 30th 2017, 15:51 |
neon1024 |
Or maybe array_flip() ? |
# |
Jun 30th 2017, 15:51 |
alexlambson |
PHP is numerically indexing the array, so isset() isn't working either. I'd have to loop and say if('role') |
# |
Jun 30th 2017, 15:51 |
jeremyharris |
sorry, array_search |
# |
Jun 30th 2017, 15:51 |
jeremyharris |
derp |
# |
Jun 30th 2017, 15:51 |
neon1024 |
Perhaps I misunderstood |
# |
Jun 30th 2017, 15:51 |
neon1024 |
https://3v4l.org/IAq7H |
# |
Jun 30th 2017, 15:50 |
neon1024 |
I’m not sure it would @jeremyharris as it would be numerically indexed |
# |
Jun 30th 2017, 15:49 |
jeremyharris |
@alexlambson hash usually expects multidimensional arrays. In your example, a simple isset would work |
# |
Jun 30th 2017, 15:47 |
phpnut |
What defines traditional? |
# |
Jun 30th 2017, 15:46 |
phpnut |
Yes but there was an issue with some OS and public |
# |
Jun 30th 2017, 15:46 |
tariquesani |
@phpnut If I remember right 'webroot' was considered more semantic when compared to public |
# |
Jun 30th 2017, 15:45 |
alexlambson |
Does anyone know how to check for a value with hash? eg. ``` $array = [ 'role', 'district' ]; Hash::check($array, 'role); ``` The above doesn't work for me. 'role' is being treated as a value because PHP makes it into a `int => string` array. |
# |
Jun 30th 2017, 15:05 |
phpnut |
But it shows how easy CakePHP is to modify to fit a specific need |
# |
Jun 30th 2017, 15:04 |
phpnut |
We did use public for webroot back in the early days but it causes some issues, I don't remember why I changed it for sure. |
# |
Jun 30th 2017, 15:02 |
phpnut |
@joepferguson yes it is. Glad to see you like it |
# |
Jun 30th 2017, 15:02 |
irongomme |
@dereuromark but beforeRules is triggered after validate , does it ? |
# |
Jun 30th 2017, 15:01 |
dereuromark |
presence of ID probably |
# |
Jun 30th 2017, 15:01 |
dereuromark |
"Instead use beforeMarshal if it should always be run - or if it only applies to saving, beforeRules." |
# |
Jun 30th 2017, 15:01 |
irongomme |
@jeremyharris , thx, but how can I detect in beforeMarshall if it is a creation or edition ? |
# |
Jun 30th 2017, 15:00 |
dereuromark |
@irongomme See https://github.com/dereuromark/executionorder/blob/master/RESULTS.md#model-validate--save |
# |
Jun 30th 2017, 15:00 |
jeremyharris |
or, use a setter on the entity |
# |
Jun 30th 2017, 15:00 |
joepferguson |
@phpnut Last time I seriously played with Cake was the early 2.x days. It’s awesome to see how far it’s come :) |
# |
Jun 30th 2017, 14:59 |
jeremyharris |
that happens *before* the request data becomes an entity and before validation |
# |
Jun 30th 2017, 14:59 |
jeremyharris |
beforeMarshal is probably what you’re looking for |
# |
Jun 30th 2017, 14:59 |
irongomme |
What the way to automaticaly generate a field on before save which is not provided in the form. If i use beforeRules event to auto generate de field value, it doesnt validate because the field is not yet generated ... ? |
# |
Jun 30th 2017, 14:47 |
phpnut |
Welcome to the dark side @joepferguson muhahaha |
# |
Jun 30th 2017, 14:45 |
phpnut |
More options!!!! |
# |
Jun 30th 2017, 14:40 |
dakota |
:slightly_smiling_face: |
# |
Jun 30th 2017, 14:40 |
joepferguson |
@dakota Nothing wrong with it. Just throwing another option out there. |
# |
Jun 30th 2017, 14:38 |
dakota |
joepferguson, what's wrong with https://github.com/alt3/cakebox :slightly_smiling_face: |
# |
Jun 30th 2017, 14:36 |
jeremyharris |
what SQL are you expecting from those conditions? |
# |
Jun 30th 2017, 14:32 |
eBugg |
cake 2.9 |
# |
Jun 30th 2017, 14:31 |
eBugg |
https://gist.github.com/anonymous/9207c618493b75c812e9d049773b5dd6 |
# |
Jun 30th 2017, 14:30 |
adriencs |
Cake 2 ? |
# |
Jun 30th 2017, 14:30 |
adriencs |
look weirdo |
# |
Jun 30th 2017, 14:30 |
eBugg |
but I pull $lista from $this->request-data and the format is wrong |