Problem

In the following situation:

  • A node reference field (I've tested with an autocomplete entry, but I guess the same thing would happen with other widgets) is configured with a view defining the allowed values for the field
  • That view has an exposed filter in its default configuration
  • There's a validation error in the form before the nodereference validation (for example, a missing node title)

Then no matter what the value of the nodereference field is, there will be a validation error for the nodereference field saying that this content can't be referenced.

Steps to reproduce

  1. Install Drupal 6.12, CCK 2.4, Views 2.6
  2. Enable Views, Views UI, Content, NodeReference
  3. Create a new node view, add a few field and an exposed filter
  4. Add a new nodereference field to an existing Content type, with an autocomplete widget.
  5. Choose the view created in step 3 as the source for the allowed values
  6. Try to create a new node of the type choosen in step 4, without a title but chosing a node from the autocomplete dropdown.

Expected result:
A validation error for the title field

Actual result:
Two validation errors: one for the title field, and another saying Field name: this post can't be referenced.

Patch
The reason is rather simple: in view::build, Views check with form_set_error for potential errors in the exposed form, and aborts early if there is. This means that there's never any result, and leads the nodereference validation to think that this content isn't an allowed value.

Attached patch fixes it by redefining the uses_exposed() method in the content_plugin_display_simple, telling Views to completely ignore exposed filters for Views with a display of either content_plugin_display_simple or content_plugin_display_references.

CommentFileSizeAuthor
cck_noderef_view_no_exposed.patch646 bytesDeFr
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

yched’s picture

Status: Needs review » Fixed

Sounds reasonable, committed. Thanks !

Status: Fixed » Closed (fixed)

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