How can I display a message when "add another item" on an Inline Entity Form Multiple field is clicked? In Drupal 8 inline entity form is there a "form_alter" or "submit handler" or some type of ajax callback for when a user clicks "add another item"?

What I would like to do is display a message to the user when they click "add another item" on a Inline Entity Form Multiple field.

Struggling to find the right path.
You can do this using JS. Add a click event listener on the Add item button. When the button is clicked you set a message.

Something like this should work:

$('.add-item-class').on('click', function () {
  const messages = new Drupal.Message();
  messages.add('You clicked the add item button!');
});


Make sure you have Drupal available in your JS file by adding it as a dependency in your libraries file.

js:
  path/to/js-file.js: {}
  dependencies:
    - core/drupal
    - core/jquery


Please note that the Drupal.Message() was first introduced in Drupal 8.7, so if you use an older version it would not work.

Another possible solution is to create a route that sets the message, using \Drupal::messenger()-&gt;addMessage('').

Your controller will do like this:

\Drupal::messenger()-&gt;addMessage($this-&gt;t('Your added an item!'));
$messages = ['#type' =&gt; 'status_messages'];
return new JsonResponse(['message' =&gt; Json::encode(\Drupal::service('renderer')-&gt;renderRoot($messages))]);


And your JS file like this:

$('.add-item-class').on('click', function () {
  $.get('/path/to/your-route', function (response) {
    $(context).find('.region-highlighted').prepend(JSON.parse(response.message));
    setTimeout(function () {
      $(context).find('.region-highlighted .messages').remove();
    }, 5000);
  });
});



This appends the message to the highlighted region and removes it after 5 seconds. You can place it anywhere you want.