# |
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 |
# |
Dec 1st 2017, 16:51 |
phantomwatson |
Er- yeah. |
# |
Dec 1st 2017, 16:51 |
meder |
the opposite |
# |
Dec 1st 2017, 16:51 |
phantomwatson |
Do you mean there's no problem if you only use `newEntity()` but the problem occurs if you use `patchEntity()`? |
# |
Dec 1st 2017, 16:51 |
meder |
it's definitely not validation. this isn't associated, but there are other associated tables being saved (they save fine. everything is fine but this one field) |
# |
Dec 1st 2017, 16:51 |
meder |
why would my entity not save a field with a 'leader_id' on creation but only on patch entity? |
# |
Dec 1st 2017, 14:42 |
hmic |
kant, you just need to pass the 3 function arguments like your api description says |
# |
Dec 1st 2017, 14:42 |
bravo-kernel |
+1 for twig, solid choice/move guys :thumbsup: |
# |
Dec 1st 2017, 14:28 |
hmic |
this is a standalone plain php function, it does not use anything cakephp, it is completely selfcontained |