Comments

mr.york’s picture

StatusFileSize
new17.28 KB

First patch.

mr.york’s picture

Status: Needs work » Needs review
StatusFileSize
new19.58 KB

Add endpoint label settings for relation field widget.
Clear related entity cache when saving a relation.

Chris Gillis’s picture

Why has this not been done anywhere yet? It seems like such a core piece of functionality to the relation module. I was about to code my own field for a system I'm building and then I found this... but I'm hesitant to use the "relation add" module which is centered around a "block". Is this a departure from the purpose of the module? Does anyone have advice for me of other discussions / attempts that have been made around this desired functionality?

Chris Gillis’s picture

Actually, it seems like this functionality exists in: http://drupal.org/project/relation_select. Care to comment on differences?

mr.york’s picture

StatusFileSize
new20.05 KB

Next version.
Fixed relation field save.
Fixed display label name.

mr.york’s picture

Status: Needs review » Fixed

Commited patch.

nagy.balint’s picture

The main advantages of relation add module:
- uses a different widget which is less problematic and more node reference like
- it lets you fully use the fieldable relations, cause you can fill the additional fields when you create the connection, relation select does not have this functionality.

kork’s picture

Great module! Thanks a lot!

The dropdown for the releation type isn't set when editing a node. On line 527 it should be
'#default_value' => isset($type) ? $type : NULL,

it would be nice to store the resulting relation ids with the field, so one can use the delta to change the weight. do you accept patches?

mr.york’s picture

Thank you!
Fixed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

kork’s picture

Version: 7.x-0.1 » 7.x-1.0-beta1
Status: Closed (fixed) » Needs review
StatusFileSize
new1.38 KB

I've got some fixes for special cases here: I have directional relations on the same node type and restrict the field only to those relations. This patch fixes the relation_type_load call for reversed releations and replaces the reverse relation detection by looking at the endpoint data.

mr.york’s picture

StatusFileSize
new2.16 KB

Use coding standards, please.
I fixed the relation type select issue with the field widget.

scottrigby’s picture

This patch is looking great!

The only issue I ran into is when two content types share the same directional relation field, one with a reverse endpoint - when a relation is deleted from one field instance, it still appears in the other, until a cache clear.

Quick proof of concept (not a patch, but I can add one if this seems reasonable):
In function relation_add_field_update():

foreach ($items as $key => $item) {
    if (isset($item['delete']) && $item['delete']) {
      if (isset($item['relation_options']['rid']) && $item['relation_options']['rid']) {
        relation_delete($item['relation_options']['rid']);
+        cache_clear_all('field', 'cache_field', TRUE);
      }
      continue;
    }

It would probalby be better to target the individual field cache directly - something like what relation_add_entity_presave() does, but checking each bundle the field may be part of…

scottrigby’s picture

StatusFileSize
new531 bytes
new2.16 KB

Ok patch and interdiff attached.

mr.york’s picture

Status: Needs review » Closed (fixed)

Please do not reopen this issue, if you find any problems open a new issue for it. Thanks.

scottrigby’s picture

@mr.york #15 is a confusing response given your patch in #12.

In any case, should I open #13/14 as a separate issue?

mr.york’s picture

No, I've commited all patches.