FieldWidget for the multyselect entity reference fiels does not work correctly. It attachs right. But It renders nothing. Look two screenshots to find a problem.
| Comment | File | Size | Author |
|---|---|---|---|
| #30 | 2156649-followup.patch | 1.35 KB | amateescu |
| #23 | interdiff.txt | 1.12 KB | amateescu |
| #23 | 2156649-23.patch | 12.08 KB | amateescu |
| Screenshot from 2013-12-14 16:17:21.png | 64.72 KB | Anonymous (not verified) | |
| Screenshot from 2013-12-14 16:17:41.png | 50.94 KB | Anonymous (not verified) |
Comments
Comment #1
Anonymous (not verified) commentedThe problem was that the variable is modified because we send it as an object by reference. I copied the instance of the object.
Comment #3
Anonymous (not verified) commentedComment #4
Anonymous (not verified) commentedI ran --class "Drupal\entity_reference\Tests\EntityReferenceAutocompleteTest" without patch. It showed everything OK.
Comment #5
Anonymous (not verified) commentedI can not find a test for multiple values.
Comment #6
andypostproper component
Comment #7
andypostSo just extend one of existing tests to multple items, it's not clear how to reproduce bug
Comment #8
jrockowitz commentedI can confirm the issue described and the patch provided by likin in comment 3 fixed the issue.
Comment #9
Anonymous (not verified) commentedComment #10
Anonymous (not verified) commentedComment #11
Anonymous (not verified) commentedComment #12
Anonymous (not verified) commentedComment #13
Anonymous (not verified) commentedThis patch, task exposes new two problems:
* entity_reference_create_instance does not support FieldDefinitionInterface::CARDINALITY_UNLIMITED
https://drupal.org/node/2167975
* $entity_loaded->{$this->fieldName}->count() always return ammount + 1. $entity_loaded->{$this->fieldName} also contains empty object.
Comment #14
dawehnerIf this clone is really required you should at least explain why
The codestyle of drupal adds a linebreak here.
It would be maybe helpful to exlain what is checked...
A kind of unit test is certainly great here, but I wonder whether having a webtest would be kind of helpful here, given that this is some actual high level user problem.
Comment #15
Anonymous (not verified) commentedIt makes from multi value to a single value.
We need clone $items.
Comment #16
johnpitcairn commentedPatch at #12 applies to D8 alpha 7, and fixes a problem where only the first field value is loaded when editing a node with a multiple-value entity reference field, and saving the node destroys subsequent field values.
Comment #17
amateescu commentedHere's another approach which doesn't mess with the $items object anymore by moving that piece of functionality to a separate helper method.
I also brought in the complete tests from #2160575-27: Option widgets integration is broken for the entity reference field which covers multiple values properly.
Comment #18
dawehnerIs there a reason why this should be part of this patch?
Comment #19
amateescu commentedThat's because the new tests expose a bug in the 'tags' widget so I needed to bring in the fix as well to get them to pass.
Comment #22
dawehnerMh I wonder whether we could document this new regex, these are just always hard to understand.
Comment #23
amateescu commentedFair enough :)
Comment #26
amateescu commentedI manually stopped the testbot since we have a backlog of 150 (!!!) patches and the last patch is just about some new comments (and the one from #17 passed).
Comment #27
amateescu commentedComment #28
berdirThanks, this should be ready then, nice clean-up and comes with tests :)
Comment #29
catchCommitted/pushed to 8.x, thanks!
Comment #30
amateescu commentedOops, this patch needed a small update after #2164827: Rename the entityInfo() and entityType() methods on EntityInterface and EntityStorageControllerInterface.
Comment #31
amateescu commentedCommitted by @catch: 60fb1aa.
Comment #32
yched commentedI don't really understand the logic of
getEntityIds($items, $delta)
getLabels($items, $delta)
- If they're supposed to work on a specific $delta, why would they return an *array* of ids / labels ?
- AutocompleteWidgetBase::getEntityIds($items, $delta) receives a $delta but doesn't use it, instead it iterates on all $items ?
- The override in AutocompleteWidget returns only the id for the specific $delta ?
Related : I would really welcome anyone able to work on #2175343: Pass a FieldItem instead of FieldItemListInterface in WidgetInterface::formElements :-)
Comment #33
berdirThat's because entity reference has two different autocomplete widgets, one with a text field per item and one that lists all. This dates back to 7.x code, we just switched to a less crazy override for that use case.
Comment #34
yched commentedWell, then it seems the two implementations of getEntityIds() are actually different use cases that cannot really live in the same method under the same contract / phpdoc ?
Comment #35
amateescu commentedWell, the use case to get entity IDs from the $items array, one widget needs all of them and the other needs just the one matching a delta. I'm not sure why this is so different..