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.
To reproduce the issue:
1. Install Field Collection module.
2. Create a Field Collection field on an entity with multiple allowed values.
3. Create a DER field in the Field Collection with multiple allowed values.
4. Create an instance of the entity and add an additional Field Collection.
The first field collection's Entity Type field will sometimes interfere with the second field collection's entity types for the autocomplete field.
Comment | File | Size | Author |
---|---|---|---|
#14 | make_the_js_class-2862964-12.patch | 2.77 KB | jibran |
|
Comments
Comment #2
gradywring CreditAttribution: gradywring commentedAttached a patch that uses the target.id of the Entity Type select list instead of a class as its jQuery selector. This ensures the .parents() call only returns one DOM element and the correct autocomplete field is affected by the Entity Type value change.
Comment #3
larowlanTo reproduce this issue
That sounds like a world of pain.
But onto more serious things...
Target IDs change with each ajax request.
Will this work after you hit 'add another' for example.
Core has worked actively to move away from IDs, towards
data-
attributes. If class is no good, I'd prefer we did that here instead of using ID.Comment #4
gradywring CreditAttribution: gradywring commentedI'm going to be honest with you, when I saw the requirements for this feature I thought, 'Well, how am I supposed to make that?' It's basically a block type that can display a 'flexible grid' of entities. So, a field collection represents each row and a DER field represents each column in that row.
Using ID's it did work after 'add another'. However, using data attributes is much better. Good catch. I've rolled a new patch and tested with my use-case.
Comment #5
larowlanthanks
Comment #6
larowlanthis looks good to me
Comment #7
jibranCan someone please check DER+Paragraphs?
Comment #8
jibranThe JS test failed.
Comment #9
jibranThe problem here is that the name is not unique. I made the name unique using
$element['#name']
. I tested it with unlimited cardinality der field on the node form with unlimited cardinality paragraph field with unlimited cardinality der field and unlimited cardinality field collection field with unlimited cardinality.Comment #10
jibranEvery field has the same name as well.
Comment #11
jibranComment #14
jibranIt is a JS class so @rikki_iki suggested to add
js-
prefix to the class. @dpi said$js_class = Html::cleanCssIdentifier("dynamic-entity-reference-{$name}[target_type]");
is not readable so updated that as well.Here is the resultant classes screenshot.
Comment #15
dpiComment #18
jibranThanks, committed and pushed to both branches.