I wanted to see what API functions are available for field collections. I would assume there's a hook_field_collection_load(), a hook_field_collection_view_alter() and I nor other developers shouldn't be expected to dive into entity.module code and classes to figure out what hooks there are available to implement.
Comments
Comment #1
tim.plunkett/me nods
Comment #2
kmhanser commentedI concur.
trying to figure out how field_collections render their output so I can alter it slightly before display, and I can't find where to hook in.
are there any hooks for field_collections? or should i just start hacking the module...?
Comment #3
tim.plunkettActually, field_collection has no hooks or alters of its own.
Both the field collection and the field collection items are fields, so they are subject to the hooks of the Field API.
For example, if I have a content type named 'tour' with a field collection named 'field_tour_date', and I want to change the name of the 'edit' link, here is code you could use. (This uses
hook_field_attach_view_alter().)Obviously you could just change the edit text in the UI, but you could have certain cases you wanted to change it.
Comment #4
dave reidThat seems odd. There should be hooks like hook_field_collection_item_load/update/save/view right? Sometimes I don't want a hook that will get invoked for every entity load, but just for a specific entity.
Comment #5
tim.plunkettAnd I would have gotten away with it if it weren't for that meddling Dave Reid!
I forgot that Entity API provides hooks for every module that integrates with it.
Comment #6
tim.plunkettMost of this can be copied straight from http://drupalcode.org/project/profile2.git/blob/refs/heads/7.x-1.x:/prof...
Comment #7
jmuzz commentedThe documentation for these functions was added to field_collection.api.php somewhere along the way.