You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Custom fields are reset to 0 when an object is stored outside its edit form #527
Every save reads $_POST.w2p_Core_BaseObject::hook_postStore() (BaseObject.class.php ~line 765) runs on every store(). It builds w2p_Core_CustomFields for the object and calls bind($_POST) and store(), whatever request is running.
Missing fields become 0.w2p_Core_CustomFields::bind() (CustomFields.class.php line 158) sets every field that is not in the input to 0. It does that because an unchecked checkbox (CustomFieldCheckbox, line 19) posts nothing.
Result: any store() from a request that doesn't contain the object's edit form silently zeroes that object's custom fields. That includes:
AJAX or JSON saves;
imports (w2p_Actions_ImportTasks);
hook_cron work in queuescanner.php;
other modules saving an object as a side effect.
Worth auditing: a secondary object stored during another object's form post binds the first object's posted values, e.g. tasks updated by a parent or dependency recalculation inside a task save.
Intended solution
Checkboxes always post.CustomFieldCheckbox renders <input type="hidden" name="<field>" value="0"> before the checkbox. A missing key then genuinely means "not in this form".
A form marker. The custom-fields block of an edit form emits a hidden w2p_cf[<module>]=1.
Activity