Log message #4105284

# At Username Text
# Dec 20th 2017, 22:43 braeden Good morning/afternoon everyone
# Dec 20th 2017, 22:09 josexato Good afeternoon what would be your suggestion in order to make an array of entities from an array of ids from that kind of entity?
# Dec 20th 2017, 21:55 spencdev What is the best way to access the current user on Events?
# Dec 20th 2017, 21:48 cgtag I want to update my description on the team page for the cake website. I can't remember which repo in github that belongs too?
# Dec 20th 2017, 21:47 cgtag I'm back after about a year away from the slack channel. Sorry for disappearing. Not that anyone would remember me. lol
# Dec 20th 2017, 21:47 cgtag hello all
# Dec 20th 2017, 21:13 spencdev or whichever you are.
# Dec 20th 2017, 21:13 spencdev yessir
# Dec 20th 2017, 21:13 greenjam94 oh gotcha, thanks for your help
# Dec 20th 2017, 21:12 spencdev yeap, it has something to do with how they handle the token differently. One puts it in the header, and the other puts it as a form input
# Dec 20th 2017, 21:11 greenjam94 I mean it works for every other thing I’ve done so far with cake, but trying to send a request over AJAX it fails
# Dec 20th 2017, 21:10 greenjam94 Oh, Interesting I didn’t know that
# Dec 20th 2017, 21:10 spencdev I'm not sure why, but I had the same issue awhile back ago.
# Dec 20th 2017, 21:09 spencdev Can't use Security and Csrf at the same time
# Dec 20th 2017, 21:08 greenjam94 File uploaded https://cakesf.slack.com/files/U8H4R4KNV/F8JNBTJEB/-.php / https://slack-files.com/T053DPNCM-F8JNBTJEB-c56cedea1f - <@U43JSV0SK>
# Dec 20th 2017, 21:06 greenjam94 can I create a snippet here instead of gist?
# Dec 20th 2017, 21:05 spencdev where you load `$this->loadComponent('Csrf');`
# Dec 20th 2017, 21:04 spencdev your controllers `initialize` function
# Dec 20th 2017, 21:04 greenjam94 Sorry, my initialize?
# Dec 20th 2017, 21:03 spencdev Can you gist your initialize @greenjam94
# Dec 20th 2017, 20:40 greenjam94 Hi, I need to submit a form over ajax, I have a X-CSRF-TOKEN as explained in https://book.cakephp.org/3.0/en/controllers/components/csrf.html#csrf-protection-and-ajax-requests but it errors because _Token is missing from the form. Any suggestions?
# Dec 20th 2017, 20:09 night_wulfe I'm not sure, sorry. I haven't used patchEntities before.
# Dec 20th 2017, 19:58 kailas @night_wulfe i’m trying to just do a save with associated entities. in my form I have a set of fields that have hte fields for each of the associated entities to update. however, when I do patchEntity, it doesn’t merge the new values, but just overwrites the values in the associated entities. does that make sense? why would that be occuring? I thought it would just merge in changes but leave the unchanged fields as they are
# Dec 20th 2017, 19:38 night_wulfe @kailas
# Dec 20th 2017, 19:38 night_wulfe https://book.cakephp.org/3.0/en/orm/query-builder.html#updating-data
# Dec 20th 2017, 19:38 night_wulfe I'd use the Query Builder and execute the SQL directly.
# Dec 20th 2017, 17:50 kailas or if i iterate through associated entities, and then save once, will the save be a bulk update?
# Dec 20th 2017, 17:48 kailas Is there a way to update many records at one? similar to a update (foo left join bar on foo.id=bar.foo_id) set foo.a=‘asdf’ where bar.blah=something (my syntax may be a bit off, but hta’t sthe concept). rather than iterating through my results and updating/saving one at a time?
# Dec 20th 2017, 16:23 spencdev Then after the post, `patchEntity($varNameOfEntity, $this->request->data())`
# Dec 20th 2017, 16:17 spencdev That's typically how it is. Because when you post, you are technically reloading the page. So you should create your entity once, before the `request->is(['post'])` I know that's is 3.x, I can't really remember what the 2.x was
# Dec 20th 2017, 16:16 devito i think what is happening is I am declaring my entity 2x. once on page load and then again on post
# Dec 20th 2017, 16:14 spencdev and also, make sure your form is pointed to the same action that you are using to show the form. In other words, unless you specifically need it to go to another action, leave the `url` option blank.
# Dec 20th 2017, 16:13 spencdev ^ I literally almost had that exact thing typed
# Dec 20th 2017, 16:12 hmic devito: 1. don't redirect on error, 2. make sure you set the actual patched, failed saving, entity to the form at creation time! (or an empty entity on first load without submitting data)
# Dec 20th 2017, 16:11 devito hmm ok. let me take another look.
# Dec 20th 2017, 16:09 dereuromark it should not redirect, but stay on the page, including all errors on the form inputs. and only after success you can redirect away
# Dec 20th 2017, 16:08 dereuromark reloads? then you messed up the form building.
# Dec 20th 2017, 16:07 devito Noticed something odd, after a form submission fails because of Model rules the page doesnt seem to accept the next form post. it reloads the page and the user has to start again. Is there a way to refresh a page after a failed save and cary over the entity errors?
# Dec 20th 2017, 14:56 admad All with* methods return a new instance
# Dec 20th 2017, 14:55 admad @jotpe your example code did not work because you did not assign the return value of withStringBody() to a var.
# Dec 20th 2017, 14:28 vignesh.pattalam yes just realised, I thought you were linking to a plugin initially that did it