I've got a reasonably complex family of node type relationships. I can get the editors to deal with the idea that in order to edit certain complex data, they have to edit it on the incoming (referring) node, not the target node that they are looking at.
But - it's therefore neccessary that they can get to the referrer nodes when looking to edit the target node.

I can display the incoming references on node view, that works fine, and is what the module does well.
But if the editor hits 'edit' the edit screen simply doesn't show those incoming properties, even in read-only mode, and it's disconcerting plus not-usable for them.

I hit into the code, and found that all we really have to do is provide a 'widget' for the nodereference field type. It doesn't have to be a working widget like #667224: Allow the reference field to be edited, but it should be something. In the first case, a list of links to the incoming references.

Code was easy, and comes out clean : like this:

/**
 * Display incoming nodereferrers on an edit form. They can't be edited here,
 * but can be at least listed
 * 
 * Implimentation of hook_widget. Defines the appearance of this field type on
 * the node edit form.
 */
function nodereferrer_widget(&$form, &$form_state, $field, $items, $delta = 0) {
  if ($field['widget']['type'] == 'nodereferrer_list') {
    $output = array(
      '#title' => $field['widget']['label'],
      '#type' => 'fieldset',
    );
    // $items is always a list - a list that contains a list of incoming referrers.
    // So - display the list, using the default formatter.
    foreach ($items as $i => $item) {
      $info = array('#item' =>  $item);
      $output[$i] = array(
        '#type' => 'markup',
        '#value' => theme('nodereferrer_formatter_default', $info),
      );
    }
    return $output;
  }
}

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dman’s picture

andypost’s picture

Idea is good but not complete!!!
I think we need a field-setting to "enable" this feature to make this configurable

dman’s picture

Actually, on my first crack at it, I just provided an extra widget of my own in the field settings.
Alongside "Read only list", I had my own "list of links to incoming references" and you could therefore choose if it should show on the edit for or not by selecting either the old or new widget. That was fine, and I could do it from my own module without even patching.

BUT.
When reading "Read only list" next to my text, i figured ... well that implies that you are supposed to ... see a read-only list in the space for this widget you are configuring.
So, my patch now means that - if you select "read only list" - you get a read only list. Patch accomplished per what the widget says it does.

What we need now is an alternative widget renderer called "do not display" that provides the old, incorrectly labelled behavior!

And if we are multiplying widgets (which is fine), my use-case finds it most useful to have a third option - "list of 'edit' links" that will allow an editor to jump from editing node B to editing node A without that "view" page in between