Log message #4100291

# At Username Text
# Dec 1st 2017, 18:49 slackebot2 that would work too. Thanks
# Dec 1st 2017, 18:49 randompherret I have a small app that is recording some data in 3 tables. I need to generate a report I know I can just add an action to an existing controller but I want to make sure I would do it the same way as I would in a bigger app in case this grows. Is it recommended to just add it to whatever controller would fit the best, to the pages controller, or make a new one? I'm not finding anything useful on google so if someone has a link to read
# Dec 1st 2017, 17:04 meder hmm, no but i'll double check
# Dec 1st 2017, 17:04 meder it's a fk
# Dec 1st 2017, 17:03 hmic is that leader_id used in any association in the table? - even ones you dont provide/save?
# Dec 1st 2017, 17:03 phantomwatson In that case, I think it defaults to making all fields accessible. So that's not it.
# Dec 1st 2017, 17:02 meder every other field works fine though
# Dec 1st 2017, 17:02 meder no $_accessible defined
# Dec 1st 2017, 17:02 meder i didn't bake anything - there's just one getter function there
# Dec 1st 2017, 17:01 phantomwatson If you baked all of that and didn't add `leader_id` after baking, then the line `'leader_id' => true` should be in there somewhere.
# Dec 1st 2017, 17:01 phantomwatson Open up `/src/Model/Entity/Order.php` and look for a property called `$_accessible`.
# Dec 1st 2017, 17:00 meder where would i see that?
# Dec 1st 2017, 16:59 phantomwatson Hm. `leader_id` is listed in `Order::_accessible`, right?
# Dec 1st 2017, 16:57 meder for new records, it does newEntity and patch with request->data()
# Dec 1st 2017, 16:57 meder wait. i think it patchEntity's regardless
# Dec 1st 2017, 16:56 meder err, newEntity*
# Dec 1st 2017, 16:56 meder phantomwatson: my entity is 'order' and the field is 'leader_id'. the field exists when i debug($orderEntity); right after ->errors() check, which is after patchEntity
# Dec 1st 2017, 16:55 meder no buildRules, no existsIn
# Dec 1st 2017, 16:55 hmic in the table, method name buildRules()
# Dec 1st 2017, 16:55 phantomwatson Ohhh, I get it. Was `leader_id` recently created? You may need to delete the model cache in /tmp/cache/models for Cake to recognize it.
# Dec 1st 2017, 16:55 hmic do you have any rules in the table? - like e.g. existsIn?
# Dec 1st 2017, 16:54 meder really? rules? hm
# Dec 1st 2017, 16:54 hmic can still be rules
# Dec 1st 2017, 16:54 hmic it's not validation if it's in the entity
# Dec 1st 2017, 16:54 hmic interesting
# Dec 1st 2017, 16:54 phantomwatson Ahh, check your validation rules for "create" versus "update" triggers.
# Dec 1st 2017, 16:54 meder it's the save
# Dec 1st 2017, 16:53 meder that's what i just debugged
# Dec 1st 2017, 16:53 hmic so is it the newEntity or the save?
# Dec 1st 2017, 16:53 meder yes
# Dec 1st 2017, 16:53 hmic meder, check the entity returned by newEntity() does it have the field set?
# Dec 1st 2017, 16:53 phantomwatson (This Phillip Emerson guy gets tagged an awful lot when I'm around :slightly_smiling_face: )
# Dec 1st 2017, 16:53 meder and the condition to do that is correct as well
# Dec 1st 2017, 16:53 meder but this particular page has a condition for new or patch
# Dec 1st 2017, 16:53 meder the problem only occurs when i save a new record. it's never in updating a record
# Dec 1st 2017, 16:52 phantomwatson Are you always saving new records to the database, or is this sometimes when you're updating existing records too?>
# Dec 1st 2017, 16:52 meder getErrors() returns an empty array
# Dec 1st 2017, 16:52 meder there is no beforeSave changing/removing it
# Dec 1st 2017, 16:52 meder 100% not a typo
# Dec 1st 2017, 16:51 meder and all the other fields work fine
# Dec 1st 2017, 16:51 meder it doesn't save 'leader_id' on newEntity save