Log message #4100297

# At Username Text
# Dec 1st 2017, 19:48 h.mavisakalian I get an error while saving data to database
# Dec 1st 2017, 19:47 h.mavisakalian Hey Guys
# Dec 1st 2017, 19:43 obinoob I need to know if I can stop it to save the empty field?
# Dec 1st 2017, 19:41 obinoob the second "deep" association level !
# Dec 1st 2017, 19:41 obinoob I have field with validation rules that go through the following filters: ->email ->allowEmpty and ->add with options to be unique in table etc... however if empty it still gets stored and next time it will stop at unique condition... do not know if it is related with the fact that I'm using a entity with associations where emails happen to be in
# Dec 1st 2017, 18:51 dereuromark keep it simple at the beginning, you can always easily refactor in the future.
# 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