public function submitForm(array &$form, FormStateInterface $form_state) { // Get the triggering element. $triggering_element = $form_state->getTriggeringElement(); // Determine which button was clicked. switch ($triggering_element['#name']) { case 'submit': // Handle form submission. break; case 'cancel': // Handle cancel action. break; case 'delete': // Handle delete action. break; } }This code example is using the Drupal package library. The FormStateInterface belongs to the Drupal\Core\Form package.