Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When a user goes to try to create a new node using the 'create' button, I find they first enter the title in the autocomplete textarea. Seeing as they tend to do this automatically, maybe we can account for this by transferring that to the new node being created within the modal window?
I'm pretty sure this is not generalized enough, but it's suiting my purposes at the moment so thought I would let others know about it. I've simply added an onLoad
callback to Drupal.nodeRelationshipsReferenceButtons.openDialog()
Comment | File | Size | Author |
---|---|---|---|
#3 | noderelationships-node_form.patch | 1.07 KB | sirkitree |
noderelationships-node_form.patch | 1.18 KB | sirkitree |
Comments
Comment #1
sirkitree CreditAttribution: sirkitree commentedmarking as needs review.
Comment #2
markus_petrux CreditAttribution: markus_petrux commentedIt looks like a reasonable feature to add. Though, there are a couple of things that could be enhanced.
1) The onLoad callback is invoked in parent.js like this:
Note that we already have a reference to the child window and document. The first argument is a reference to Drupal.modalFrame on the parent window. So the patch could take advantage of these arguments.
2) Maybe the node title is not visible in the form (think for example about Automatic Node Titles module), so we may need to check if that form element exists and it is a text element, not disabled, and not readonly, to cover cases where other modules could be playing with this field. And that way our module could co-exists perfectly well in those cases.
Thanks
Comment #3
sirkitree CreditAttribution: sirkitree commentedHere's an update:
1) using $iFrameDocument parameter
2) checking for the form field element
3) checking that the form field element is blank (other wise it starts appending [nid:xx] to the title)
Comment #4
markus_petrux CreditAttribution: markus_petrux commented$form_title
should be declared to prevent namespace conflicts in case there is a variable with the same name defined on a higher level of javascript context. Also, this needs to be checked for cases where the title is not really available. As described in #2.2) above. We should not modify the title if the user cannot do it manually.Also something I forgot to mention in #2... sorry for that. In case where this addition is not desired, this _new_ behavior should be optional and disabled by default, so that we do not break any site out there We can add a new option to the Node Reference Extras page for each widget that reads something like "Take autocomplete text as create new title". Please note that this module is being used by a lot of sites, and new features should not break the behavior of any existing site, which is something that would require a jump to next major version number. Though, that's a job that requires time to manage, which is something I do not have right now. So, it seems to me it is better for everyone that anything new is made optional and disabled by default.
Comment #5
sirkitree CreditAttribution: sirkitree commentedI probably will not be finishing this one :( We have a need for a much more extensive manipulation of the UI which will include things like hiding the text field altogether and only displaying limited controls to the user. I'm not even sure it'll be a patch for Node Relationships, but maybe a submodule that provides a different kind of widget or ui to nodereference. I haven't started work on it yet but will bring it up for discussion when I do to try to find the best home for it.
Comment #6
schmook CreditAttribution: schmook commentedThis could be a very useful enhancement! Does the #3 patch work? And any chance of getting this into the module? Thanks for your time and effort.
Comment #7
schmook CreditAttribution: schmook commentedIn case anyone else comes across this post and has the same usability complaints from end users. I used jQuery to hide the input fields until the user creates the referenced node. It works for a specific use case where the nodes referenced will not already be existing.
Add this code to your scripts.js and rename #field_table_XXXX_values to the table ID of the referenced field.
Drupal.behaviors.removeInput = function (context) {
// hide the inputs until created
$('#field_table_XXXX_values input').css({"display":"none"});
// display each input once created
$('#field_table_XXXX_values input').change(function() {
$(this).css({"display":"inline"});
});
};
Seems to work...input is welcome on the solution.