Skip to content

Instantly share code, notes, and snippets.

@dpi
Created July 13, 2011 00:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dpi/1079482 to your computer and use it in GitHub Desktop.
Save dpi/1079482 to your computer and use it in GitHub Desktop.
Drupal Relation/References Widgets
<letharion> chx: Do you already have any thoughts on whether and how to provide a references-style field widget for nodes?
<chx> letharion: no
<chx> letharion: we will reuse the references widgets instead.
<letharion> chx: Great. Have you talked to the maintainers? Do we intend to copy their widgets into the relation codebase?
<chx> copy?
<chx> heaven forbid
<chx> this is field API
<chx> we just need to make a field type
<chx> and then alter widget info to get em in the house.
<letharion> chx: I'm not sure I follow, will references then depend on relation?
<chx> if you install references then we will reuse 'em widgets
<letharion> chx: Ok, so the widgets will not reside in the relation module. So what I could do to advance this, is to patch references to use relation as a backend?
<chx> letharion: if you want to enhance this.....
<chx> letharion: you need to write two field types based on relation
<chx> letharion: one, a directional field where r_index 1 is node:*
<chx> letharion: and then you need to implement hook_field_load, hook_field_update (will be interesting), hook_field_insert
<chx> letharion: and finally hook_field_widget_alter
<chx> letharion: makes sense?
<letharion> chx: Yes, I think so :)
<chx> oh and hook_field_storage_pre_insert
<chx> which unlike the above is a real hook
<chx> but therein you can set up fields to be skipped
<chx> which you need to
<chx> same field_storage_pre_update
<letharion> I have implemented a field previously, but I don't know what all those hooks do. I will read about them and see if I have further questions.
<chx> letharion: but first, i do not see Rules committed.
<chx> letharion: this combination will hopefully let you take over from the default storage
@dpi
Copy link
Author

dpi commented Jul 13, 2011

Related: [http://drupal.org/node/1175386](Provide widgets for specific entity types)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment