I have two content types with CCK fields. One type includes a CCK field that is a node reference, the other includes a CCK field that is a user reference. Both field are Select List widgets based on Views. The view results sets are as expected when previewing them; however, I just installed the latest Views dev version (date stamped 1256344316) and when creating content the select lists are empty. I reverted to the previous dev version (date stamped 1255998945) and the select lists are populated fine.

If you need me to provide more info I would be happy to do so - I just don't know where to look.

Comments

I am also seeing this bug on Node Reference fields using the views display option with Autocomplete textfields -- the "title" field is blank/empty. The view itself is working and the title field shows up fine in views preview. This started with the Oct. 23 release (Oct. 19 release was working fine.)

The common factor here is that I committed a patch that moves field rendering around. I didn't think it would affect other things, but it appears that this may have affected CCK. The patch I committed is #502348: How group display by mutliple fields? -- can you see if this patch has caused a problem for CCK and then we can figure out what the problem is and where it should be fixed.

The 'rendered' elements in $result array only contain markup, without real data about the fields. So we may need to change $this->row_plugin->render($row) or the code that's behind that, but honestly, this part of CCK/Views integration is kind of obscure to me. I do not understand the flow. :(

I guess it could also be related to the following snippet from nodereference.module:

// TODO from merlinofchaos on IRC : arguments using summary view can defeat the style setting.
// We might also need to check if there's an argument, and set *its* style_plugin as well.
$view->display_handler->set_option('style_plugin', 'content_php_array_autocomplete');
$view->display_handler->set_option('row_plugin', 'fields');
// Used in content_plugin_style_php_array::render(), to get
// the 'field' to be used as title.
$view->display_handler->set_option('content_title_field', 'title');

I've been bitten by this bug while upgrading to Views 2.7, attached patch against the latest CCK 3.x-dev seems to fix it. It's pretty much the same fix the Views Accordion module applied in #621568: Views 2.7 breaks views accordion

I have a content type that has a pull-down field where the allowed values are populate from a view. The content type also has fields that are a taxonomy tag (multi-select) and a pulldown text field with 3 possible values. If the view-pulldown come before (higher on the page) than the others, then the others are broken and have empty pulldowns and you can't select anything. If the view-pulldown comes after the other pulldowns, then they all work.

Since the site I am working on is complicated and has custom modules that do form_alters and etc, I set up a clean drupal install and tried to replicate the behavior. I have I so far not been able to; instead I have a separate problem; the views-populated pull down shows only the label, not the contents of the view output. (The view previews and works fine). It is a node reference that is using a view that has one filter (node published is yes) and one filed (Node: Title). In the pull down you see "Title: " for each possible selection, but nothing after the "Title:".

I also took the site I am working on and one by one disabled all the custom modules, but the problem still happens.

Eventually I will either have a version of my clean test site that produces the problem, and then I can post the whole db dump here, or I find some piece of the development site that I can disable to make it work, and I will focus on that. In the meantime if anyone has suggestions to narrow the search that would be appreciated.

As a final weird observation, this bug appears for user 1, and for at least some users with just "authenticated user" permissions everything works perfectly.

On the "clean" site I was using views 2.7. On the dev site I was using views 2.6, I upgraded to views 2.7, and the same behavior remains, except that now the view-based pull down also has no values in it. The 614292.patch above caused the views-based pull down to start working again, but any pull downs after it still do not work, unless you are not the admin user.

It continues to work better if you have a less privileged account, which I will try to use to narrow this down. I will hopefully post more on this tomorrow.

I think this might still be an issue for user reference field... When using autocomplete with advanced view selection, the autocomplete functionality puts the title field (I'm using a content profile relationship) as the final suggested input, instead of the username, and submitting gives this:

found no valid user with that name.

I'm using D 6.14 and views 2.8 (and CCK 2.6)

I very rarely reopen issues, so hopefully I'm not in the wrong here :)

In case someone else stumbles across this, I figured my issue out, but it's way to complicated a specific to do up another issue.

My advanced view selection was fairly complex, and involved a content profile relationship in order to get some of the fields I wanted displayed during user reference autocomplete. My problem (with autocomplete adding the Node:Title from the relationship instead of the User:Name) went away as soon as I added the field (Relation) Node: Title, which I didn't have before.

was wrong, still not fixed!
major problem is that $field->content in views-view-fields.tpl.php is empty (I use the raw for now to fix it). $field->content is supposed to be set in views\theme\theme.inc in template_preprocess_views_view_fields() through $field_output = $view->style_plugin->get_field($view->row_index, $id);

This call goes back to render_fields in views\plugin\views_plugin_style.inc row 31

Here it ends for me as I have no clue where this theming function is defined. Am not an expert on Views/CCK and have actually no clue whatsoever whats going on in there. Am not sure if this is a CCK or Views probelm. Can someone help me out on this?

It seems that this is a theme-related problem, which would explain why most people aren't seeing it. In particular, I've been having the problem with our own custom theme, but it went away when I switched to another theme (Garland).

In particular, the problem was solved for me when I deleted the template file "views-view-field.tpl.php" from my custom theme -- even though the file in my theme was identical to the file modules/views/theme/views-view-field.tpl.php!

Perhaps the views data aren't being correctly passed to the theme's template files, but are being correctly passed to the module's template files? I'm afraid I don't know much about how this happens. Can anybody else help out?

@BerkeleyJon: Thanks for the additionnal informations, it helped a lot to reproduce the issue over here :-)

Long story short: yes, copying views-view-field.tpl.php from views directory to your theme directory will trigger http://drupal.org/node/591804 , which means that Views preprocess functions don't applies as expected and you don't get the expected result. (There's also the fact that as long as it's only in Views theme folder, views-view-field.tpl.php isn't really applied, for performance, a function is used instead...)

Hopefully this D6 bug will be fixed at some point. Before that, you basically have two options: don't overide the field template or replace in your .tpl.php the $output variable with $field->advanced_render($row). (Alternatively, you should also be able to manually load Views theme.inc in a custom module hook_init). While testing though, it didn't look like this completely fixed the issue, so if at all possible simply don't override views-view-field.tpl.php

(For the record, what's setting the $output variable used in views-view-field.tpl.php is

It's probably broken in CCK only because it's using a custom style plugin which does as little rendering as possible, but theorically it will break everywhere if you override every Views theme function that are defined in its theme.inc )

Workaround: There is one line in views that seems to cause this problem. I'm not sure if this is a CCK or Views issue but I'm posting here to show in which file in views issue originates and how to get around this issue. Using CCK 2.6 , Views 2.10 , and Chameleon theme.

So apparently I missed the memo that you have to have Node: NID as a field in a view you're using for a nodereference field? I think previously you were supposed to make your argument validate by NID or have the default argument by "node ID from URL" or something like that, but unfortunately I don't remember exactly. Let me put it this way: I added Node: NID as a field in the view I'm using for a nodereference field, and the Autocomplete and Select widgets are both working as they should for me now. I've also realized that (unlike what I said in #34) the Autocomplete widget wasn't "really working" until I did this. I say it wasn't "really working" because it was working for nodes (that have the nodereference field) in English/default language, but not for translated (Spanish) nodes. I'm not sure what the problem was -- the nodes being referenced are images that are language neutral, could be something there.

In case it matters, here's what happened when I was using the Autocomplete widget without adding the Node: NID field to my View (very similar to what others have described, but different variables, so hopefully helpful):

When editing an English node, I was able to reference the appropriate image nodes by typing the image node titles, waiting for Autocomplete, and selecting the option that appeared (at which point the field contents "became" "I am an image node title [nid:123]").

Also, if the English node I was editing already had content in the nodereference field, the Autocomplete widget/field displayed as you'd expect, with the field contents filled in normally with the appropriate content ("I am an image node title [nid:123]")

When editing a translated/Spanish node:

If it already had content in the nodereference field (which I could confirm by viewing the node normally -- the nodereference field contents displayed correctly), the Autocomplete widget/field was empty in the node-edit form. (When I was using the Select widget, the nodereference field wasn't just blank in the node-edit form, it had the default "None" option selected.) If I saved a translated/Spanish node like this, the nodereference field was cleared (confirmed by viewing the node normally).

When entering content into the nodereference field, I got as far as selecting an image node title that appeared under the Autocomplete widget, but at that point, the field contents "became" only "I am an image node title [nid:]" -- no NID number.

If I saved the translated/Spanish node with the nodereference field just like that, I got an error message like "found no valid node with that title".

If I copied/pasted the field contents of the corresponding English node ("I am an image node title [nid:123]") and saved it, I got an error message "[nodereference_field_name]: this post can't be referenced".

As I mentioned previously (#33), I'm running Views 3 and CCK 2.6, with the two views3+CCK patches, and I've experienced variations of this bug since Views 2.7 (though I skipped from 2.8 to 3). (Earlier the bug didn't seem to delete field contents, the nodereference field/Select widget was just blank -- not "None".) I have not copied "views-view-field(s).tpl.php" (or any Views templates) into my custom theme directory (nor have I customized any Views templates in the module directory). Please let me know if there are any other details I can provide to help work on this problem. Thank you!

I've met the problem. (Views 6.x-2.10, CCK 6.x-2.6).
I had a complicated view with 2 relationships (both user and node reference).
Names of fields generated by views were strange: instead of title and nid fields, i got title for node, but nid for related field. I looked at views sql:

SELECT node.nid AS nid, node_node_data_field_modules.title AS node_node_data_field_modules_title, node_node_data_field_modules.nid AS node_node_data_field_modules_nid, node.title AS node_title

content_plugin_style_php_array_ac.php can't handle such things, so i got a listbox with only one value.

In case it is useful to anyone else I also had this problem - my node reference field was working fine but since upgrading views no longer had any items to select, and I tried the suggestion above of adding node: nid as a field to the view, and it then worked as before. You can also set the nid not to display and it still works.

I was having the exact same issue with a node reference and just a simple view - blank values. I upgraded to CCK 2.7 and Views 2.11 and the issue went away. I verified that autocomplete, radio and select lists all work.

Now, if someone could tell me how to expose a views filter in this scenario, my problems would really be solved!

Well, after a lot of reading and searching for a solution to my problem and a lot of tests, I should admit that I have no idea how to fix my problem, and that I have this problem with Drupal 6.20, CCK 2.9 & Views 2.12, so all the latest releases for D6 :

I created a NodeReference field with multiple values on a User Profile (with Content Profile) called 'Structures', a 'Structure' being a normal content type with CCK fields. From that profile, I wanted to reference items that would enable me to short list the access of the current logged in user to these items and their child nodes (a sort of custom business ACL). Then I created a 'Product' content type with a nodereference field (Selection widget) referencing a 'Structure' (for the structure manages the product, and a user has responsability for a shortlist of Product).

From there I created some other content types (lets call them X) all referencing a 'Product', all having a node reference field (selection widget) to let the user choose in a list of available Products.
My point was to use Views to restrict the products available in the select list to the ones managed by the Structures referenced in the current User Profile (complicated but necessary to explain my problem !) : with the help of the Reverse Node Reference module, I got the correct preview for my shortlist, except that in the selection widget only one result appear (I know of that problem, and read about solutions in other posts - this is not my main point here).

To get over that, I created a small module called Views Custom Prerender overriding views_pre_render(&$view) just to replace the nid row result (which was, whatever the query, the nid of the user) with the X nid (X being a content type I mentionned earlier). The outcome being that my selection list is correctly populated with the correct names and stuff, BUT :

when I try to create a X, selecting a Product in the user-customed shortlist, I have the following error message :

"This post can't be referenced".

So my problem is not about correct display of the selection list, but about validation and content population after form submission.
Following all the discussions in that list, I also looked in the nodereference.module file, line 841 :

OK, I mostly found my problem, but not how to solve it.
The problem comes that by creating a "Views Custom Prerender" override module, I messed up the query executed at validation time, during the X content type creation. Of course, the whole was a bad idea, but what to do when you have nothing else ?
Because overriding the $row->nid in the $view->result corrupted the 'INNER JOIN' clause in the auto-generated view query.

I fixed it the very very hard way, meaning adding that very ugly code to the cck/includes/views/handlers/content_plugin_display_simple.inc, line 37 :

I 100% agree with #35 - my view+select list was not working and I had no clue as to why until I found this issue. I did not realize nor did I find documentation that specified that Node:NID must be in the view.

I created a documentation patch for both CCK trees that indicate that for select widgets you need to include Node:NID in the view. That's a few hours of my life I won't get back so hopefully this will help someone else if we can get it in.

I still have issue:
- a node reference field correctly displays values for selected nodes
- the same field as exposed filter is not populated
- I tried to add a node:nid hidden field, but it did not help

Attached an export of the views
The problematic field is called "Publication" - the field is OK, the filter is not.

1) Set up a node reference
2) Choose a view to select from
3) Edit the node in question to pull the special list in

The view was built with absolutely nothing but a 'Node: Title' field. There's no trickery going on, it's a view that will spit out the title of every node created on the site. The node reference however, pulls back nothing.

Really not sure on how to approach a possible fix, because I don't think this piece of functionality works properly.

What version of CCK and Views are you using. My Node references that are using views are all not working correctly.
the auto complete ones fits all of the correct nodes as tiny, tiny lines into the small drop box. When I change it to a select list. The values are correct but the displayed values are blank. See below:

Specifically the 'rendered' field. 'title' is going through it seems, but the rendered row is coming back as an empty string.
Any thoughts as to why? This is the same scheme that is used in the jump menu for views. Labels are coming through, If I add labels to each field, the labels show up inline, but the actual field data does not.
Even if the view is executed earlier in the nodereference.module script, say line 859, 'renedered still only provides the labels for each of the fields and not the field values. Am I missing something on how to set up the view. I have three fields, and they are NID, Title, and another field.

I switched to using a table display, and I am re-using the view in multiple node references on the same page, and the first field reference has a problem, the others on the page render properly. Even if I change the order of the fields on the edit/add page the first one will not display correctly, the Rows do not render, but the second and so forth the rows will render. Is there a method to pre-render the view, so that it will work the first time through?
Has anyone else found a work around, or solved this? I am really stuck.

This is not just for the select list view, all of the node reference fields work AFTER the first one doesn't function, The widget type does not matter.