Does anyone know how to limit the autocomplete suggestions of Link Fields to only certain bundles -- not globally, but per Link Field instance? I nearly found a solution in customizing https://github.com/minnur/Alter-Entity-Autocomplete , but this is global for all autocompletes, and I need to get the calling Link Field instance somehow.


You can now use the following contributed module to solve the issue:

Link Field Autocomplete Filter

This module adds a Link Field configuration for filtering the allowed content types in the autocomplete field.


This is possible with hook form alter:

function hook_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  // if $form_id ==  'xyz'
    'target_bundles'=>['article'=>'article', 'page'=>'page'], //etc


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.