How can I detect what control caused AJAX callback? I have a form containing a table, which displays rows from a database table, and has a couple of editable fields, which is all working fine.

I now want to make one of fields trigger an AJAX callback when changed, and the callback to update another field in the same row.

Can the callback function check which instance of the changed field triggered the callback, so it knows which row to update?

Thanks for your help, and happy new year!

James
I use this code since drupal 7, only changed the first line for drupal 8:

$triggering_element = $form_state-&gt;getTriggeringElement();
if ( isset($triggering_element) ) {
  $trigger = $triggering_element['#name'];
  if ( $trigger == 'op' ) {
    $trigger = $triggering_element['#parents']['0'];
  }
}
else {
  $trigger = '';
};


If trigger is 'op', then it is a button and i get the name from the parent.

And see comment of Ivan Jaros, make the names unique.