Hello
First thanks a lot for the module that brings drupal closer to be general purpose website tool.
I need to build a master/slave form where people add references to new "lines of information" that they create in a modal form.
Seems to be exactly what create and reference is for. ;)
The trouble is that the "Plus" button stay there even after a new node has been created (and referenced) and clicking it bring up the form to create a new node whose reference, if validated will "replace" the previous one in the field.
This is absolutely counter intuitive (at the very least the button should behave like an edit button but in fact should morph in a "edit in a new form" button is the referene field is not empy) , and it means the user can create tons of "dangling" nodes that are not referenced anywhere anymore.....
Last, node relationships mandates the use of an autocomplete widget but leaves its GUI as "autocomplete" and that is really bad because :
* it means the user can change the reference field value instead of being brought to the edit form for the referenced node
* it means the user can circumvent the "create and reference" and associate a field value with ANY other referencable node..... that's very bad.
* and last, the user can do any of the above without any malicious intend just trying to do what seems to be "the right thing" .... :(
The "logical" and "expected" behavior should be :
* autocomplete must be disabled
* clicking the field should bring the "create reference" form if the "create and reference form" option is active AND the field is empty
* clicking the field should bring the edit form in any case the field is neither empty nor disabled
* the "add/plus" button should be removed when the reference field is not empty (either edition was enabled or only deletion is allowed)
In my opinion, without this, the module can potentially bring more harm than good to datas, with this it would be the complete node reference solution....
(for the autocomplete issue, I have seen http://drupal.org/node/357328 but is it a "hack" that bring lots of other issues (like internal field duplication in the solution, disabled fields not being sent back to the server that defeats the "add and reference" purpose and such))
How can we fix this ? is this something that could be done easily ? can somebody give me pointers where to look at to accomplish such things ?
I am hungry for informations since I am a bit suprised this issue had not been brought up before, so I may do something wrong :)
Thanks a lot for your time and help.
cheers
Comments
Comment #1
markus_petrux commentedAs a bug report, this issue would be "closed (works as designed)". But that hides the issue from normal view. I'm switching it to support request, and marked fixed, so it is closed by the system in a couple of weeks automagically.
The module is coded in this way because it is more open to different use cases. You may need to create a custom module that is able to customize the behavior to your particular needs.
Maybe there would be room to change things here, but anything different would have to be optional, and it would require someone to write the code. In case someone has the time for that, this issue could be switched to "feature request".
Comment #2
Annakan commentedThanks a lot for your answer.
I am not sure I understand how it is more open to different use cases compared to the cinematic I am proposing since it seems always wrong to create a new node on top of an already created one without deleting that one first... but I probably did not think enough about all the cases.
Just out of curiosity (I don't think I am up to contributing a good enough module quality wise at the moment) can you hint me where to look to customize such behavior (the display logic of buttons at the side of a referred node).
thanks again.
Comment #3
markus_petrux commentedYou could install a submit callback to the node edit form that checks changes in node reference fields, and deletes previous references if these have been changed.
You may also need to solve cases where the user cancels the node edit process in the main browser window, after a new referred node has been created from a modal frame. Should you need to remove the new node, or maybe not?
Also, you may need to react differently if a node is being referred by more than one node. In this case, you cannot remove that node when a new one has been created from a modal frame.
Also, what if a referred node should never be removed, maybe because they are part of something that is essential to your database. For example, think about recipes. When you create a recipe, you may have the chance to create a new ingredient, but the system should never remove existing ingredients, because these can be reused somewhere else, or not.
There may even be more scenarios, and maybe it is surely a complex task to try to deal with all these possibilities in the code of the Node Reference field. CCK has been evolving a lot recently, but it has never been perfect for everyone. CCK for Drupal 6 was nicer and more powerfull that CCK for Drupal 5. And now, Fields in Drupal 7 core are even better... there has been a lot of man power under the hood to reach the current stage. Still, there's room to become even better... meanwhile, Drupal has a lot of places where one can implement code to change the default behavior of almost everything. It's just a matter to know where, and sometimes that requires basic knowledge of the APIs, or maybe a bit of investigation and tests, because there may be different ways to resolve something.
Comment #5
thommyboy commentedmay i re-open this as a feature request... maybe we could also join forces to make this happen?
@Annakan
me too i'm working on a usecase that sounds similar to yours... i would like to enable the user to
- just add (multiple) new nodes and reference them
- edit one of the referenced nodes
- delete referenced nodes (delete the reference AND the referenced node...)
no need to reference existing nodes, i want to keep the actual node and the referenced nodes as "one piece of content". i know i could achieve something like this with flexifields but as i need multiple images in the child content i can't. and i like the useflow of noderelationship better (with the modalframe popup). what would be needed:
- enable "create & reference"
- switch mode to "edit" in case the field contains a nodereference already
- disable manual input for the autocomplete
- support a "delete" function
@markus_petrux
could this be done with the hooks the module provides?