Support from Acquia helps fund testing for Drupal Acquia logo

Comments

BDG92308 created an issue. See original summary.

DYdave’s picture

Title: Drupal 8 port » Port Autocomplete Deluxe to Drupal 8
Component: Miscellaneous » Code (miscellaneous)

Standardized title.

id.tarzanych’s picture

Status: Active » Needs review
FileSize
88.3 KB

Please review my patch

It's pretty raw and needs work on customization improvement and code clean-up, but I believe it can be a start point of 8.x-2.x-dev branch.

id.tarzanych’s picture

FileSize
88.97 KB

Fixed field title display

willyk’s picture

id.tarzanych did you see this issue? https://www.drupal.org/node/2838576#comment-11944808

m.abdulqader’s picture

+1

edwardchiapet’s picture

I was able to work off of @id.tarzanych's patch and make some updates based on that - including fixing PHPCS warnings/errors, adding ability for reordering, and a setting for allowing auto-creation of new terms.

I've also created a sandbox project with the D8 port for testing - https://www.drupal.org/sandbox/edwardchan/2888186.

JonMcL’s picture

Great work @id.tarzanych and @edwardchiapet!

@edwardchiapet: I did run into problems with the allow auto-creation of new terms functionality. I think you need to modify the getAutocreateBundle function to be like:

  /**
   * Returns the name of the bundle which will be used for autocreated entities.
   *
   * @return string
   *   The bundle name.
   */
  protected function getAutocreateBundle() {
    $bundle = NULL;
    if ($this->getSelectionHandlerSetting('auto_create') && $target_bundles = $this->getSelectionHandlerSetting('target_bundles')) {
      // If there's only one target bundle, use it.
      if (count($target_bundles) == 1) {
        $bundle = reset($target_bundles);
      }
      // Otherwise use the target bundle stored in selection handler settings.
      elseif (!$bundle = $this->getSelectionHandlerSetting('auto_create_bundle')) {
        // If no bundle has been set as auto create target means that there is
        // an inconsistency in entity reference field settings.
        trigger_error(sprintf(
          "The 'Create referenced entities if they don't already exist' option is enabled but a specific destination bundle is not set. You should re-visit and fix the settings of the '%s' (%s) field.",
          $this->fieldDefinition->getLabel(),
          $this->fieldDefinition->getName()
        ), E_USER_WARNING);
      }
    }

    return $bundle;
  }

This is a direct copy from the EntityReferenceAutocompleteWidget class.

Also, is the new_terms widget setting even necessary? Did you consider re-using the auto_create field setting instead?

LNakamura’s picture

Thanks, @JonMcL! That does indeed fix the auto-creation of new terms.

As for the utility of new_terms, I'd say that it allows for flexibility on a per-field basis: one field could allow new terms, while another does not, though both would be gated by auto_create.

LNakamura’s picture

Hi, all - I incorporated @JonMcL's fix, cleaned up a few typos and a coding standard issue, and created 8.x-1.x, -dev, and -beta1 releases.

We'll be working on porting a few recent 7.x-2.x-dev fixes in the near future.

Thanks!

LNakamura’s picture

Status: Needs review » Reviewed & tested by the community
LNakamura’s picture

Status: Reviewed & tested by the community » Fixed

Closing this issue since the basic port is done - new issues should be created for bugs, etc., against the D8 code.

LNakamura’s picture

Edit to credit @JonMcL on the issue....

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.