After #2555027: Support non-numeric entity ID's DER field can refer content entities with string ids but it doesn't allow config entity references at least from ui. There are no tests for this.
Add two pre-configured fields, just like ER in core, one will allow content entities and other will allow config entities so that we can keep the UX part of this issue simple.
| Comment | File | Size | Author |
|---|---|---|---|
| #36 | 2766187-36.patch | 31.14 KB | jhedstrom |
Comments
Comment #2
chx commentedI believe the API allows for this already and it's not entirely clear how UI would work as many config entities do not even have a label! Are we going to restrict to those that have one? Fall back to the id?
Comment #3
jibranComment #4
chx commentedThis is tests only ; we won't add a config entity UI as core doesn't have such either.
Comment #5
jibranJust confirmed from @dawehner that we don't need the views integration for this as well.
Comment #6
jhedstromI started in on a test (not sure if its the right approach, but it takes an existing test and then tries to reference a config entity). The test fails for a variety of reasons--one I've fixed in this patch, but the other is failing with an incorrect primitive typed data validation error (since target_id is still apparently an integer, and a config entity id is a string--an issue I thought had been resolved).
Comment #8
jhedstromAh, I'd been working on the wrong branch!
Comment #9
jhedstromThis applies, and it passes too. Do we need further tests?
Comment #11
jhedstromThis time...
Comment #12
jhedstromComment #14
jibranThank you for working on this.
We need following test cases and please create a new test file.
For last four you can update
dynamic_entity_reference_entity_test_entity_base_field_infowith states.As per #4 we don't want to expose it in field config settings form for configurable fields so just add some asserts to existing UI test to make sure it is not happening.
We also need some UI tests for autocomplete and autocreate just like
\Drupal\Tests\dynamic_entity_reference\Functional\DynamicEntityReferenceTestWe also have to update
\Drupal\dynamic_entity_reference\Plugin\Field\FieldType\DynamicEntityReferenceItem::defaultFieldSettings.Comment #15
jhedstromThis adds the 6 test cases noted in #14 to a new test class.
I have not yet updated the UI tests, so that still needs to be done. Posting here for now, I may be able to get back to this later today.
Comment #17
jhedstromThis should fix the fails, as mentioned in #14 the default settings method needs updating.
Comment #18
jhedstromThis adds the UI test.
Comment #19
jibranThank you, this's some great work.
Sorry, I missed two test cases:
Only remaining things are
These should be specfic to config entity reference.
This is still pending.
I think the second param should be FALSE by default but if making it TRUE makes the changes minimum then it's alright.
We should add some settings here.
Let's move basefield tests to separate file.
Comment #20
jhedstromThis should address nearly everything from #20. I'm now working on the additional UI tests mentioned.
That was actually added in #17.
Comment #21
jhedstromThis test is failing for config entity auto create, because core assumes any auto-created entity has a bundle. From
DefaultSelection::createNewEntity():$bundle_keycomes back as empty, leading to the test failure error (Exception: Error: Cannot access empty property). Should this be pushed to a follow-up issue since it might require fixing core?Comment #23
jibranLet's add a core bug if there is not one yet. #2405467: Add EntityType and Bundle constraint on entity property of DynamicEntityReferenceItem is in and I think we might have to adapt here.
Comment #24
jibranSorry, it was a one line thing so I missed it in the patch. :)
Thank you for the awsome work. This needs a reroll after #2405467: Add EntityType and Bundle constraint on entity property of DynamicEntityReferenceItem.
Comment #25
jhedstromI added #2822647: DefaultSelection::createNewEntity() assumes entity type has a bundle key. However, now the issue is that config entities do not auto-generate an ID, so that method probably needs further updating...
Comment #26
jhedstromStepping back for a minute, I'd say we should split auto-create of config entities off into a separate issue--I'm not aware of any config entities that could consist only of a label, and provide value...
Comment #27
jhedstromThis is a reroll, still containing the failing config auto-create test.
Comment #29
jibran+1 to #26. Let's get this in.
Comment #30
jhedstromI added #2823371: Add support for auto-create config entities as a follow-up. We probably still need the autocomplete test though.
Comment #31
jhedstromThis removes the auto-create test, and adds an autocomplete test for config entities. Anything left to do here?
Comment #32
jibranI think we are almost ready. Just wait for #2729463: List of view_modes is empty in dynamic_entity_reference_entity_view formatter then we can commit this. #2458353: DER fields should add selection handler config dependencies will become a bug after this so should we move it here? Just few minor observations and thanks for the new patch and tests.
Do we need this? I don't think so. views data for config entities, it doesn't make sense unless I'm missing something?
We can just use labels as is without passing TRUE to getEntityTypeLabels().
Comment #33
jhedstromGood call on those changes in #32. For the views one, config entities were already being excluded because of the sql storage check, so removing that makes the code clearer.
I will look into rolling the test from #2458353: DER fields should add selection handler config dependencies into this patch.
Comment #34
jhedstromThis rolls in the test from #2458353: DER fields should add selection handler config dependencies, and finishes the
@todoin that patch.Comment #35
jibranThank you! for adding #2458353: DER fields should add selection handler config dependencies into this. #2729463: List of view_modes is empty in dynamic_entity_reference_entity_view formatter is fixed now. It maybe needs a reroll. Let's get this fixed as well.
Comment #36
jhedstromRebased off of latest 2.x.
Comment #38
jibranThanks! committed to 8.x-2.x