Steps to reproduce:

  1. Install CCK3 (currently alpha or -dev) and node relationships on D6+i18n.
  2. Setup Drupal with at least two languages
  3. Create a new test content type (translatable).
  4. Add at least one node reference field (which allows to add translatable "story" nodes) and a second field for testing purpose, like a text field.
  5. Group the two fields inside a multigroup.
  6. Set the node reference field to use the "add and translate" feature provided by node relationships module.
  7. Create a new test node and set one or more stories on the node reference field inside the multigroup.
  8. Translate the node

The expected behaviour would be to have the node relationships link for adding a new translation of the untranslated related node.

Instead the multigroup removes the original node reference field which will be substituted by the plain node reference field: theme_content_multigroup_node_form() uses drupal_render() in order to regenerate the fields inside the multigroup form.

It looks that node relationships alters the form with _noderelationships_parent_node_form_build_translation_settings() (called by _noderelationships_parent_node_form_alter()) but after doing that CCK3 regenerates the fields.

Comments

finex’s picture

Quick update: only the "translate and reference" link is not rendered, instead the other node relationships buttons are correctly rendered.

finex’s picture

Status: Active » Needs review

I've found and solved the bug. The problem is due to a wrong regexp in the Drupal.nodeRelationshipsReferenceButtons.getDelta()

In the current -dev version of noderelationships (file node_form.js) the function is:

Drupal.nodeRelationshipsReferenceButtons.getDelta = function(elementName) {
  var delta = elementName.replace(new RegExp('^[-_a-z0-9]+\\[([0-9]+)\\]\\[nid\\]\\[nid\\]$'), '$1');
  return (/[0-9]+/.test(delta) ? parseInt(delta) : -1);
};

Unfortunatly the "name" property of the nodereference field inside a multigroup field (CCK3) has the following structure:
group_NAME[DELTA][field_NAME][nid][nid]

The fix is easy: just exclude the whole substring after the DELTA with a simple ".*".

Drupal.nodeRelationshipsReferenceButtons.getDelta = function(elementName) {
  var delta = elementName.replace(new RegExp('^[-_a-z0-9]+\\[([0-9]+)\\].*$'), '$1');
  return (/[0-9]+/.test(delta) ? parseInt(delta) : -1);
};

I hope this fix will be applied.

Thanks