- 🇮🇹Italy kopeboy Milan
Would be nice to have a settings page to allow the site builder to enable it per entity type or form id
- Status changed to Needs work
9 months ago 12:35am 20 February 2024 - 🇩🇪Germany donquixote
I don't think this is the way to do it.
First, the patch contains some unrelated changes that have potentially harmful side effects.
- $(".node-form :input").each(function() { + $("." + contentType + "-form :input", context).each(function() {
The basic idea of filtering for context here is good, but this does not work if context is an element within the `.node-form`.
E.g. if you have an ajaxified element inside the node form, then inputs within the ajax-loaded content will be filtered out.Put a multiple-value link field in the form. Click "Add another item". Edit the new value. Navigate away.
The edit protection dialog won't show up. - 🇩🇪Germany donquixote
Secondly, the code treats the Drupal.behaviors.* object as a namespace, which is not really how this is normally done.
The common pattern for globally available functions seems to beDrupal.modulename.foo = function () {...}
.It is not wrong, but it is generally good to follow familiar patterns.
- 🇩🇪Germany donquixote
For this specific issue, I think a good solution would be to use php to add a class to the form, and then in js just pick up that class.