Is there any way to add this exra field on other entites like paragraphs ?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Musa.thomas created an issue. See original summary.

Musa.thomas’s picture

Title: Add support for entity D8 » Add support for all entity D8
Musa.thomas’s picture

Here a quick patch to available on all entity. I know it's not optimized and we should have settings (in admin form or I think the best is to have checkbox option per bundle when you edit it).

Musa.thomas’s picture

here the patch for the 1.8

Musa.thomas’s picture

The patch #4 have some issue with composer.json

  • micropat committed ba8deeb on 8.x-1.x
    Issue #2919756 by Musa.thomas: All entity support
    
    Add support for all...
micropat’s picture

Status: Active » Fixed

Thanks for the initial patches! Commit ba8deeb in the dev branch is optimized similar to what you suggested. A new hook is introduced to make the addtoany extra/pseudo-field available to other entity types. Usage example in a custom module:

/**
 * Implements hook_addtoany_entity_types_alter().
 *
 * @param array $types
 *   The entity types.
 */
function my_module_addtoany_entity_types_alter(&$types) {
  // Add the "taxonomy_term" entity type to make the
  // addtoany extra/pseudo-field available for tags, etc.
  $types[] = 'taxonomy_term';
}

The new hook was favored over new checkboxes in AddToAny settings because we'd like to avoid overcomplicating the options. Patches are welcomed if there are ideas for elegantly exposing the many bundles & entity types in AddToAny settings. Perhaps a form field that autocompletes multiple entity IDs, or some better approach?

Status: Fixed » Closed (fixed)

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