Attempt to find nested/referenced text field values for content suggestions

Created on 30 May 2025, 5 days ago

Problem/Motivation

The AI Content Suggestions module currently looks for text fields in the node form. There are instances where it would be valuable to extract text fields from referenced items in the form. For example, an associated Media item with an extracted text field of the uploaded document could be used to suggest content. Another example would be the description fields on referenced taxonomy terms.

There's already similar handling for Paragraph entities:

                // If we already have a paragraph of the correct type, just
                // reuse it.
                $paragraph = ($paragraph && $paragraph->bundle() == $bundle) ? $paragraph : $this->entityTypeManager->getStorage('paragraph')
                  ->create([
                    'type' => $bundle,
                  ]);

                foreach ($this->getAllTextFields($paragraph, $form[$name]['widget'][$key]['subform']) as $machine => $label) {
                  $identifier = implode(':', [$name, $key, 'subform', $machine]);
                  $options[$identifier] = $field->getLabel() . ' (' . $key . ') > ' . $label;
                }

Steps to reproduce

Proposed resolution

Attempt to load referenced entities and add any data from the fields on that entity that are text fields.

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Active

Version

1.1

Component

Other Submodules

Created by

🇺🇸United States jhedstrom Portland, OR

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @jhedstrom
  • 🇺🇸United States jhedstrom Portland, OR

    I added some proof-of-concept code that works. Some refinement would be needed to get this fully working across all entity types, etc.

  • Merge request !641Extract text from referenced fields → (Open) created by jhedstrom
  • Pipeline finished with Failed
    5 days ago
    Total: 228s
    #510609
  • First commit to issue fork.
  • Pipeline finished with Failed
    2 days ago
    Total: 205s
    #512033
  • Pipeline finished with Failed
    2 days ago
    Total: 247s
    #512217
  • Pipeline finished with Failed
    2 days ago
    Total: 203s
    #512224
  • Pipeline finished with Success
    2 days ago
    Total: 291s
    #512228
Production build 0.71.5 2024