Been searching and searching...not sure if this is possible.

Depending upon the content type a user is creating, I would like my node reference field "Product" to show a different list of allowed values (either autocomplete field or select list). Is it possible to set a certain view, per content type, as the Nodes the can be referenced?

Thanks!

Comments

flying_q’s picture

Well, 5 minutes later I came up with a pretty easy solution. With my limited PHP knowledge, I can not find a way to over-ride the global settings for a node reference field. So, what I did was created a new node-reference field, and referenced only the data type I want the user to filter on.

The node reference field that I actually want to populate is now hidden. However, I created a rule that says at time of save of the node, copy the NID from the new node reference field (the one with the only values I want the user to see), to the hidden node reference field. All works well.

Bricks and Clicks Marketing’s picture

Can you describe how you did this in a bit more detail? I am trying to limit cck field options on a node/add page based on a View with nid as argument. The view works fine but I can get it to work on the node/add page.

Arp Laszlo
bricksandclicks.marketing
design / theming / development / consulting

WorldFallz’s picture

Not sure I understand the question-- but yes, you can use a view to provide the list of nodes in a nodereference field, it's right in the settings for the field.

flying_q’s picture

Thanks for the response WorldFallz - I was not clear in my original question. When you specify a view as an allowed values list for a nodereference field, that is assigned Globally. Any other content type that uses that nodereference field will also be stuck using that view as the allowed list. I have a few content types that use the same nodereference field, however I would like to restrict the allowed values list to a different subset of values per content type.

My solution to this was to create a second 'dummy' node reference field on the content type and restrict the allowed values list of these fields as I wish. Then, on node-save I would copy the value of the dummy field to the actual field I would like the data maintained in (this field is searched on in a rather complex query).

WorldFallz’s picture

Ah ok-- yes, those settings are global field settings. If you want different settings on the config page you need to use a different field.