When "Use fallback behavior when editing content" is turned on the new node form at node/add/TYPE/NID does not have my node reference field displayed.

I believe this is because of a if on line 396

<?php
  if (isset($referenced_nid) && (empty($field['widget']['edit_fallback']))) {
    $element[0]['nid'] = array(
      '#title' => $field['widget']['label'],
      '#type' => 'nodereference_url',
      '#field_name' => $field_name,
      '#default_value' => $referenced_nid,
    );
  }
?>

I think this is a mistake but I do not know what one is trying to catch here

Comments

batbug2’s picture

Yep, same problem here.

Solved by changing that line #396 to

if (isset($referenced_nid) && (!empty($field['widget']['edit_fallback']))) {
hefox’s picture

Status: Active » Needs review
StatusFileSize
new528 bytes

I believe it's trying to catch the case that the field has not already been set to something (ie a select or autocomplete).

quicksketch’s picture

Status: Needs review » Fixed
StatusFileSize
new1.4 KB

Thanks hefox for the patch! I hadn't thought about using the $element['#type'] as the check, but it seems like it works really well. The only problem I found was that it did not work well when editing a node that was using the "leave blank" mode (it would delete any existing value). To fix this, I made the "leave blank" option fallback to autocomplete during edits if using the fallback behavior during edit (we're already doing this for the "page not found" mode).

quicksketch’s picture

Title: Use fallback behavior when editing content kills field on add form » Use fallback behavior when editing content prevents prepopulating on the add form

Status: Fixed » Closed (fixed)

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

perforator’s picture

Why didn't the patch make it into 1.6?

perforator’s picture

Status: Closed (fixed) » Needs review

Reopening since the patch is still not included. It works for me but some maintainers should take a look at it.

quicksketch’s picture

Status: Needs review » Closed (fixed)