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.
Description:
There are some troubles with the Linkit Module in combination with Module Inline Entity Form.
At inline editing the referenced Content in a Node - uploading a new image for example, the following error appears in the console:
Uncaught TypeError: Cannot read property 'fields' of undefined <strong>(Console in Chrome)</strong>
It's happening that "linkit" is not available in linkit_fields.js on line 12.
The solution is to check before if "settings.linkit" is undefined or not.
Please find attached a patch for this.
Comment | File | Size | Author |
---|---|---|---|
#20 | linkit-dashboard.patch | 626 bytes | dpacassi |
#5 | 2207651-linkit-undefined-fields-5.patch | 422 bytes | hefox |
#2 | js-error-linkit-undefined-2207651.patch | 528 bytes | mahalo13 |
Comments
Comment #1
anonOk, have you submitted a patch for this issue? I can't see it in here.
Comment #2
mahalo13 CreditAttribution: mahalo13 commentedComment #3
mahalo13 CreditAttribution: mahalo13 commentedComment #4
hefox CreditAttribution: hefox commentedCan just combine this two one line
if (settings.linkit == undefned || settings.linkit.fields == null) {
..
Comment #5
hefox CreditAttribution: hefox commentedalso wasn't relative so couldn't apply it in make file
Comment #7
hefox CreditAttribution: hefox commented5: 2207651-linkit-undefined-fields-5.patch queued for re-testing.
Comment #8
hefox CreditAttribution: hefox commentedPatch is being used on a project with multiple testers/developers and has not presented any problems yet and has fixed the issue.
Test failures make no sense
Comment #11
joelpittet5: 2207651-linkit-undefined-fields-5.patch queued for re-testing.
Comment #13
joelpittetFrom what I understand, this happens when you have an HTML editor on the page with linkit support enabled but have not created a linkit profile for that editor if I understand correctly?
This just masks the error?
Another approach would be to create warning alert to the developer that they need to create a Linkit profile for this field or editor?
This approach seems reasonable and I'm marking as RTBC nevertheless and leave it to the maintainer to decide what they want to do in regards to dealing with the JS error.
Comment #14
joelpittetComment #15
Agileware CreditAttribution: Agileware commentedActually this can happen with fields that intentionally do not have linkit enabled, and the patch in #5 fixes that case.
Comment #17
anonThanks for the patches, and for the testing.
The patch in 5 is now commited.
Comment #19
hessam61 CreditAttribution: hessam61 commentedThis is still happening. I upgraded to latest version of ckeditor and linkit. Running jQuery 1.10
Comment #20
dpacassiComment #21
anonWhat version of Linkit?
Comment #22
dpacassiI'm using linkit with the version 7.x-3.1.
Sorry, i had problems posting the text to my patch from before.
Hope that it comes now:
In addition to patch #5 (where I changed the if statement to):
I also had to update the linkit.dashboard.js file as followed (see included patch on #20):
If you're using paragraphs, you might need to include these lines as well:
Make sure to clear all your drupal caches after making these changes.
It should work afterwards (well, it did for me).
Cheers!