1

I've implemented a custom field that needs to store data outside of the Field Storage mechanism and in a custom DB table. (The field structure is enough to require a second table, but not enough to justify creating a new entity type. It's an image field with tooltips that will be later styled with JS.) I've hooked the necessary functions and I can see that the data is getting saved to the table, but the load hook doesn't get called when the edit screen form is built, nor does it's additional content show up in the passed-in $items array.

Since hook_field_widget_form doesn't get the $entity being edited, I can't manually query the auxiliary table for the data. How do I get the data into $items and onto the form so the user can edit again?

(It also doesn't appear to be calling hook_field_load on the node load either, but I haven't started working on the field formatter yet.)

1 Answer 1

0

hook_field_load is being called, but only once after a cache clear. Either the loaded field or the whole node is cached somewhere. Remember to clear your caches!

I missed the initial load because I had yet to instrument the function with the typical bevy of dpm() and ddebug_backtrace() calls. Also the function itself isn't loading the data back properly, but that's outside the scope of the original question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.