# |
Jul 21st 2017, 14:54 |
jay |
mirec Testing is easier than it looks |
# |
Jul 21st 2017, 14:54 |
jeremyharris |
bernat _joinData is a special parameter that add items to the join table entity |
# |
Jul 21st 2017, 14:53 |
jeremyharris |
subject isn’t even passed to the listener arguments |
# |
Jul 21st 2017, 14:53 |
jeremyharris |
birdy247 so I had to look it up because I don’t use magic arguments, but everything after the first argument passed to the listener should be the data |
# |
Jul 21st 2017, 14:53 |
mirec |
ok so I will try to write tests too. I think naming tables when baking migration snapshots would be nice feature, so I will code it |
# |
Jul 21st 2017, 14:52 |
bernat |
It's weird using _joinData as a model name, also it's not documented and I don't remember having it used like this |
# |
Jul 21st 2017, 14:51 |
jeremyharris |
it’s definitely worth learning |
# |
Jul 21st 2017, 14:51 |
bernat |
Hi. Is this answer the correct one? https://stackoverflow.com/questions/32969433/cakephp-3-save-extra-data-in-join-table |
# |
Jul 21st 2017, 14:51 |
neon1024 |
Great time to learn! |
# |
Jul 21st 2017, 14:51 |
jeremyharris |
we can help with that mirec :slightly_smiling_face: |
# |
Jul 21st 2017, 14:50 |
mirec |
guys, can I make some new feature to cakephp (migrations plugin) without writing tests? is there somebody who could write tests after I make pull request? cause I do not know how to do it properly :)) |
# |
Jul 21st 2017, 14:50 |
jeremyharris |
ok so you are using the magic arguments, not $event->getData |
# |
Jul 21st 2017, 14:50 |
birdy247 |
i.e. $start |
# |
Jul 21st 2017, 14:50 |
birdy247 |
instead its the optional data I send it |
# |
Jul 21st 2017, 14:49 |
birdy247 |
i.e. an instance of the subject with access to its properties |
# |
Jul 21st 2017, 14:49 |
birdy247 |
in the listener, the 2nd param is not what I expect |
# |
Jul 21st 2017, 14:49 |
jeremyharris |
I’m confused - what’s the problem birdy? |
# |
Jul 21st 2017, 14:48 |
birdy247 |
it is* |
# |
Jul 21st 2017, 14:48 |
birdy247 |
I thought it would be It is |
# |
Jul 21st 2017, 14:48 |
neon1024 |
@birdy247 Shouldn’t the second param be `$this` which would be an instance of the table class, assuming your event name |
# |
Jul 21st 2017, 14:38 |
devito |
thanks guys |
# |
Jul 21st 2017, 14:38 |
devito |
nice. ill check out the security component for this |
# |
Jul 21st 2017, 14:38 |
birdy247 |
in my listener, the 2nd argument is the value of start |
# |
Jul 21st 2017, 14:37 |
birdy247 |
I am dispatching that from my SettingsTable |
# |
Jul 21st 2017, 14:37 |
jeremyharris |
if the field is hidden, the security component will protect it from being tampered with |
# |
Jul 21st 2017, 14:37 |
birdy247 |
$event = new Event('Model.Settings.afterStart', $this, [ 'start' => $start ]); |
# |
Jul 21st 2017, 14:37 |
jay |
Or use SESSION |
# |
Jul 21st 2017, 14:37 |
jay |
Hidden values you can maintain with a hash |
# |
Jul 21st 2017, 14:36 |
mirec |
yep, set it manually or you can validate it |
# |
Jul 21st 2017, 14:36 |
mikesmoniker |
The Security component can prevent people from messing with which fields are submitted but I don’t think it works on values. You’d probably need to just manually set model in your action or use a model event to set it based on something. |
# |
Jul 21st 2017, 14:35 |
devito |
i think i read somethign about it in the cookbook but dont recall off the top of my head |
# |
Jul 21st 2017, 14:34 |
devito |
is there a way to prevent form tampering? I want to explictly set the model name in my forms and dont want a user inspecting and changing it on me |
# |
Jul 21st 2017, 14:33 |
devito |
yea that would be a bad thing to forget hehe |
# |
Jul 21st 2017, 14:33 |
devito |
mm |
# |
Jul 21st 2017, 14:33 |
mirec |
do not forget two column index on (model, foreign_key) in your images table |
# |
Jul 21st 2017, 14:32 |
devito |
yea |
# |
Jul 21st 2017, 14:32 |
mirec |
yep I see... so Posts->hasMany('Images', ['conditions' => ['model' => 'Posts'], 'foreignKey' => 'foreign_key']) |
# |
Jul 21st 2017, 14:31 |
devito |
a post can have many images |
# |
Jul 21st 2017, 14:31 |
devito |
yea im tinkering with the assoiation configs now |
# |
Jul 21st 2017, 14:31 |
mirec |
why do you have foreign_key in images table? why not Posts.image_id ? |
# |
Jul 21st 2017, 14:30 |
devito |
I would just simply need to update the model column to point to the correc tmodel |