By Raf on
Title says it all, really. This doesn't seem to come automatically with CCK, so I'm wondering if there's a way to have a node reference field create a node of that type if there's no related node yet.
To be more precise: I'm listing developers in a project content type. I want to have another content type that has more info on each developer. If people first have to check if that dev. node already exists and make it if it doesn't before they add it in a project content type, it's too much hassle. If they can fill in a field, which suggests the right dev (so typos and such're avoided as much as possible). If no dev. is found, there'll automatically be a new dev. node created upon submission.
Comments
_
... I would start looking at modules Rules, Trigger and Action .....
My guess is you will be able to do what you are looking for with these tools.
.
Thanks for the input. Couldn't get this done with actions. Been looking into its API and then realized I could just use hook_nodeapi() instead. But not for an autocomplete node reference field. It's now a regular textfield that I turn into a custom node reference using hook_nodeapi. Works like a charm now, although it's vulnerable to typo's. Guess people entering that type of content just shouldn't make typoes then :P And even if they do, it's easily corrected, thanks to the magic of not $op == 'save' or $op == 'update', but $op == 'presave' :D
I'm looking for the exact
I'm looking for the exact same operation - I'm creating a wishlist for users. I'd like each wishable item as a node so i can make statistics in Views (most wished items etc), but obviously i can't think of everything. So an autocomplete-field which generates a new node if it doesn't exist would be great.
How exactly did you achieve this?
.
I actually did it like described earlier in this topic. Here's the setup and the code, though.
1) A regular text-field, visible for the user
2) A node reference field, hidden from the user
Then, using hook_nodeapi(), I do the following:
The only thing it doesn't do, is set status to the same status as the node that's just been created (easy enough to fix, though), but I'm sure you'll be able to go on with this.
I just found this module
I just found this module http://drupal.org/project/autocreate
Maybe that works?