For use relation objects in custom widget is useful to move relation query from "hook_field_prepare_view" and "hook_field_widget_form" to the "hook_field_load". Result of the relation_dummy_field_field_load should be $items filled by IDs of relations.

Comments

Honza Pobořil’s picture

Status: Active » Needs review

Could you commit this patch if you agree?

Status: Needs review » Needs work

The last submitted patch, relation-dummy.patch, failed testing.

Honza Pobořil’s picture

Btw, are you agree with this feature? I don't want to waste my time with writing tests if this feature is not welcome.

naught101’s picture

Component: Dummy_field » API

This seems intuitively reasonable, however I'm not sure about the benefit, or whether there might be some drawbacks. What's the rationale? Are you sure this is the sensible thing to do?

naught101’s picture

Status: Needs work » Needs review
StatusFileSize
new863 bytes

Why not just do this?

Also, relation_dummy_field really needs some tests. This seems to work, but I'm a bit worried about it breaking something else.

naught101’s picture

Status: Needs review » Closed (won't fix)

Because https://api.drupal.org/api/drupal/modules!field!field.api.php/function/h... says loading fieldable entities in hook_field_load is a bad idea (possibilities of infinite recursion).