If the node form is reloaded due to an error (e.g. missing title), the modal node reference popup no longer works. If you click the link to create a new referenced node, the form loads in a new page.

It appears that modal_noderef.js is not loaded in this scenario.

CommentFileSizeAuthor
#1 no_js_after_error-1132226-1.patch1.56 KBpaulmckibben

Comments

paulmckibben’s picture

Version: 6.x-1.1 » 6.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new1.56 KB

The problem is that you cannot rely on hook_form_alter to add javascript, because if the form is cached, and it fails validation, the javascript will not be re-added if the form is reload.

The attached patch uses an #after_build function to add modal_noderef.js. The #after_build function is called even when the form is reloaded after failing validation.

Please review and let me know if I need to change anything. I look forward to this being incorporated into the module.