问题
I'm attaching images to a content type - 'marketplace item' - using the node reference url widget. The technique is outlined in full here: http://drupal.org/node/599672
My goal is to add an extra button to the image node edit form that will allow users to save and add another image node, retaining the node references/relationships for this new image node.
Therefore the buttons will be:
[Save] [Add another image] [Preview]
There are modules that provide 'add another' functionality (here and here), but they will not retain the node relationships out of the box when another node is added.
At the moment, when the user clicks the 'save' button on the image node they are redirected to the referenced node, where they can click the 'Add image' button again (created by the node ref url widget). I see you can add functions to a submit button over and above the normal submission process, so is it possible to simply activate the 'Add image' button on the referenced node again automatically via a function on the image node's submit button?
i.e. on submission of the image node:
- Save the node as normal
- Go to destination (set via the node ref widget to go to the original, referenced node)
- Activate the 'Add image' button on this node
(Obviously I'll need to retain the original 'Save' button and create a new one via hook_form_alter, but for clarity's sake let's assume this is done!).
回答1:
you're using CCK, right? just set Number of values to "unlimited" in particular field settings (/admin/content/types)
Regards, Slava
来源:https://stackoverflow.com/questions/6347580/drupal-creating-add-another-buttons-on-node-edit-forms-that-will-retain-node