Problem/motivation
Linkit widget, when setting data-entity-substitution hardcode the substitution based on the entity type
https://git.drupalcode.org/project/linkit/-/blob/7.x/src/Plugin/Field/Fi...
The bug is not visible when searching for an entity from node form because the value get updated by JS using the proper substitution defined in config.
Steps to reproduce
- Edit Media matcher
- Set Substitution Type to Direct URL to media file entity
- Configure a link field to use linkit widget
- Create a node and populate the link field with a media
- The generated link point to the actual file
- Edit the node and save without change
- The generated link point to /media/mid/edit
Proposed resolution
Linkit widget must load the substitution as by profile configuration, Hardcoded solution can be used as fallback
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | linkit--linkit-widget-has-hardcoded-substitution-3589257-2.patch | 1.64 KB | marco.pagliarulo |
Issue fork linkit-3589257
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
marco.pagliarulo commentedPatch for
Comment #4
mark_fullmerUsing the Linkit Profile configuration matchers' substitution_type, if present, makes sense. I just have a small optimization suggestion for the code. Can we avoid multiple instances of
$entity->getEntityTypeId() === 'file' ? 'file' : 'canonical';? I think the code would execute the same if we just move$substitution_type = $entity->getEntityTypeId() === 'file' ? 'file' : 'canonical';aboveif ($matcher) {, then remove the else fallback.Comment #5
marco.pagliarulo commented@mark_fullmer thanks for the reply. I refactored the code as you suggested moving
above.
Comment #7
mark_fullmerThanks for the refactoring! This looks good. Merging!