I'm using field_group with my own UI, so I need to be able to drive it programmatically. At the moment, there's no function to load a field group - The closest is field_group_menu_load(), but this means feeding in some extra params.
I'd suggest adding a function called field_group_load(), which does nothing but load a field group, move the loading code out of field_group_menu_load() into there and call it. The new function would match up nicely with the existing field_group_save().
Will make a patch for this if I get the time, but if anyone else would like to do it in the meantime that's cool :)
Comment | File | Size | Author |
---|---|---|---|
#3 | split_load_function-1276506-3.patch | 1.37 KB | rupertj |
#1 | field_group_load-1276506-1.patch | 1.08 KB | Hydra |
Comments
Comment #1
Hydra CreditAttribution: Hydra commentedI agree, the function of field_group_menu_load should be used in field_group_load. Hope this is waht you mentioned.
Comment #2
Stalski CreditAttribution: Stalski commentedThis patch will not do and I think @rupertj meant that field_group_menu_load should delegate into a more APi function, like field_group_load.
Just renaming the function won't do the job. For instance the last parameter is a map argument of "load arguments" in the menu registry. We can't expect people to call that function with all those required parameters.
So I think the best we can do is take out a portion of the function, like:
Comment #3
rupertj CreditAttribution: rupertj commentedStalski's got it spot on there. Although, I'd be tempted to move the data unpacking inside the load function, as you'll need to do it to get a properly loaded object.
$mode needs adding as a param too.
The attached patch does all this, and seems to work for me.
Comment #4
Stalski CreditAttribution: Stalski commentedyeah, that seems correct indeed. Thx for the patch. I'll look at it asap.
Comment #5
nils.destoop CreditAttribution: nils.destoop commentedPatch has been tested and committed to dev. Thx :)
Comment #6
casey CreditAttribution: casey commentedUhhh this causes a namespace issue with og.module and field.module in DrupalDefaultEntityController::attachLoad().
Comment #7
rupertj CreditAttribution: rupertj commentedAh, that's not so great... How about we rename field_group's field_group_load() to field_group_group_load()? Would be nice if the save function was renamed too to keep it consistent, and also avoid another potential clash.
Comment #8
Stalski CreditAttribution: Stalski commentedI guess we will have too.
Comment #9
nils.destoop CreditAttribution: nils.destoop commentedi changed the load, delete and save function.
Comment #10
casey CreditAttribution: casey commentedYike this is so nasty. Now the field_group module itself is considered to implement hook_ENTITYTYPE_LOAD for entity type group. Maybe we should ask the maintainers of og.module to rename its entity type to og_group.
Comment #11
casey CreditAttribution: casey commented#1295566: Rename entity type "group" to "og_group"
Comment #12
Stalski CreditAttribution: Stalski commentedHmm, This is nasty indeed. It seems waiting on #1295566: Rename entity type "group" to "og_group" will be the issue.
Wouldn't it be better to just call the function _field_group_load() for now? I can't think of any other function names that would help this issue. Maybe field_group_api_load ...
Comment #13
Stalski CreditAttribution: Stalski commentedThere is also a duplicate issue at #1297858: Please rename function again where a patch is posted for "field_group_load_field_group", which is acceptable too.
Comment #14
Stalski CreditAttribution: Stalski commentedThis is pushed to git with the solution of "field_group_load_field_group" as name of the API function. I hope everyone can live with this (temporary solution).