Score:0

How to fire the autocomplete after input reach 3 characters

sa flag

I am setting a view for the autocomplete feature of a widget with the following code:

function my_module_field_widget_entity_reference_autocomplete_form_alter(&$element, FormStateInterface $form_state, $context)
{
  $field_name = $context['items']->getName();
  if ($field_name == 'my_field_name') {
    $element['target_id']['#selection_handler'] = 'views';
    $element['target_id']['#selection_settings']['view'] = [
      'view_name' => 'a_wiew_id',
      'display_name' => 'a_display_name_id',
      'match_operator' => 'CONTAINS',
    ];
  }
}

Is-it possible to add a key/value to #selection_settings to fire the autocomplete only if the user have typed 3 characters? (or any other idea)

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.