Autocreate for Entity Reference selection handlers that extend ViewsSelection

Created on 15 September 2016, almost 8 years ago
Updated 19 May 2024, about 1 month ago

Problem/Motivation

Autocreate a is a great UX option for Entity Reference fields. Currently it is not available if you choose "Views" as the "Reference method", which is necessary if you want to filter the available choices.

Proposed resolution

Create an auto create EntityReferenceSelection plugin which extends ViewsSelection.

Remaining tasks

See #96
See #98
Review

User interface changes

Entity reference field type will have one more reference method Views: Filter by an entity reference view and allow autocreation.
When this option is selected and Create referenced entities if they don't already exist is checked, new referenced entities with title will be created. If more then one bundle exists for referenced entity, then a Store new items in select option will be shown to choose the bundle.

API changes

None.

Data model changes

None.

Feature request
Status

Needs work

Version

11.0 🔥

Component
Views 

Last updated about 4 hours ago

Created by

🇬🇧United Kingdom jonathanshaw Stroud, UK

Live updates comments and jobs are added and updated live.
  • Usability

    Makes Drupal easier to use. Preferred over UX, D7UX, etc.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States smustgrave

    This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.

    CI failures in the last few patches.

    Such a feature will need a change record.

    Curious though if we are auto creating any kind of entity reference. What happens if it's a reference to, say articles, how is it auto creating articles?

  • First commit to issue fork.
  • last update 11 months ago
    Custom Commands Failed
  • last update 11 months ago
    Custom Commands Failed
  • last update 11 months ago
    29,821 pass, 2 fail
  • last update 11 months ago
    29,827 pass
  • Status changed to Needs review 11 months ago
  • 🇮🇳India narendraR Jaipur, India

    Re #87: Fixed CI failures & added CR.

    Curious though if we are auto creating any kind of entity reference. What happens if it's a reference to, say articles, how is it auto creating articles?

    It will create an article with the title passed in input box.

  • 🇮🇳India narendraR Jaipur, India

    Update IS also.

  • Status changed to Needs work 11 months ago
  • 🇺🇸United States smustgrave

    Cleaning up credits for bad rerolls

    CR looks good.

    Tested this out on a Umami Install, since that's what I had running
    Created an Entity Ref view that searches for Tags title and filters by just Tags taxonomy vocabulary
    updated Article content type to use new handler.
    Created an Article and added "This is a test" to the tags field
    It was created BUT it was added to the wrong vocabulary. Was added to Recipe category not tags

  • Status changed to Needs review 11 months ago
  • 🇮🇳India narendraR Jaipur, India

    Hi @smustgrave, Thanks for the review.

    Created an Article and added "This is a test" to the tags field
    It was created BUT it was added to the wrong vocabulary. Was added to Recipe category not tags

    This might be because Store new items in might be selected as Recipe on the created field. If this is not the case, can you please provide a screen recording so that I can reproduce the steps?

  • Status changed to RTBC 11 months ago
  • 🇺🇸United States smustgrave

    Retested on a fresh install and seems to be adding to the correct vocabulary now.

  • last update 11 months ago
    29,912 pass
  • last update 11 months ago
    29,947 pass
  • last update 11 months ago
    29,954 pass
  • last update 11 months ago
    29,954 pass
  • last update 11 months ago
    29,954 pass
  • last update 11 months ago
    29,959 pass
  • last update 11 months ago
    29,959 pass
  • last update 11 months ago
    29,960 pass
  • last update 10 months ago
    29,968 pass
  • last update 10 months ago
    30,050 pass
  • last update 10 months ago
    30,057 pass
  • last update 10 months ago
    30,057 pass
  • Status changed to Needs work 10 months ago
  • 🇳🇿New Zealand quietone New Zealand

    I'm triaging RTBC issues .

    I read the issue summary and then the comments. I then read the change record and scanned the patch. I have found some more things to do here which I will list below.

    But first, thanks for working on this, it does look like a handy feature!

    1. This is adding to the UI, therefor adding 'usability' tag
    2. The proposed resolution has not been updated since this issue was created and there was a change to the approach in #54/#55. That should be checked.
    3. The points raised in #60 have not been addressed.
    4. #61 points out a change of behavior. I checked the change record and it is not discussed there. The change of behavior should be added there, perhaps in before/after sections. How disruptive is this change?
    5. Sadly, I don't see that there has been a code review since #60. There were a lot of rerolls after that but quite a few do not have interdiffs
    6. The term 'autocreation' is used throughout the MR but it is not an English word so should be changed. It is not identified because it appears in the core list of misspelled words in core. And there is an issue to correct all the spellings and remove that list.
    7. I think the change record needs a more informative title and that the CR itself can be made easier to understand. It should explicitly how/where to use this new feature. That is, that it when adding a reference field to an entity. The screenshot is helpful but I wasn't sure what is new about it. It is just the addition of the new option? Does selecting the option then offer more fields? I also am not sure what 'new referenced entities with title will be created" means. There is some help for this, Write a change record for a Drupal core issue .
  • last update 10 months ago
    30,056 pass, 1 fail
  • 🇳🇿New Zealand quietone New Zealand

    I made a few tweaks to the MR but it still needs work.

    I changed the MR to avoid spelling errors and sorted use statements in one file.

  • last update 10 months ago
    30,056 pass, 1 fail
  • 🇳🇿New Zealand quietone New Zealand

    There is one test file changed here, \Drupal\Tests\field\Functional\EntityReference\Views\SelectionTest. It adds the test module, 'views_entity_test'. However, if the line is removed the test still passes.

    And related to that, what is the purpose of the duplicate plugin in, \Drupal\views_entity_test\Plugin\EntityReferenceSelection\TestViewsWithAutoCreateSelection?

    This all make me think the question raised in #58.5 about testing, and answered in #59.5, needs to be looked into again. And a fail test will be needed here as well. If I knew more about views testing I would offer a suggestion.

    Adding tags I should have done earlier.

  • First commit to issue fork.
  • last update 10 months ago
    30,061 pass
  • 🇮🇳India narendraR Jaipur, India
  • last update 10 months ago
    30,137 pass
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7 updated deps
    last update 9 months ago
    Custom Commands Failed
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MariaDB 10.3.22
    last update 9 months ago
    Custom Commands Failed
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update 4 months ago
    Custom Commands Failed
  • 🇩🇪Germany tobiasb Berlin

    tobiasb changed the visibility of the branch 2800875-autocreate-entity to hidden.

  • 🇩🇪Germany tobiasb Berlin

    tobiasb changed the visibility of the branch 2800875-autocreate-for-entity-D8 to hidden.

  • 🇩🇪Germany tobiasb Berlin

    tobiasb changed the visibility of the branch 11.x to hidden.

  • 🇩🇪Germany tobiasb Berlin

    tobiasb changed the visibility of the branch 2800875-autocreate-for-entity to hidden.

  • Assigned to tobiasb
  • 🇩🇪Germany tobiasb Berlin
  • Pipeline finished with Failed
    3 months ago
    Total: 208s
    #123230
  • Pipeline finished with Canceled
    3 months ago
    Total: 79s
    #123287
  • Pipeline finished with Running
    3 months ago
    #123288
  • Pipeline finished with Failed
    3 months ago
    #123671
  • Pipeline finished with Failed
    3 months ago
    Total: 171s
    #123677
  • Pipeline finished with Failed
    3 months ago
    #123683
  • Pipeline finished with Failed
    3 months ago
    Total: 177s
    #126508
  • Pipeline finished with Success
    2 months ago
    Total: 993s
    #145620
  • Pipeline finished with Failed
    2 months ago
    Total: 569s
    #157371
  • Pipeline finished with Success
    about 2 months ago
    Total: 658s
    #164787
  • Issue was unassigned.
  • Status changed to Needs review about 2 months ago
  • 🇩🇪Germany tobiasb Berlin

    I added a new constraint AutoCreateEntityBundleExists; but I have no idea how to test it on the drupal way. I know there are other constraints, but their looks easier.

  • Status changed to Needs work about 1 month ago
  • The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

Production build 0.69.0 2024