How to find the pressed button
In the foreach loop of your example, you create multiple buttons and you can set a different/distinct '#name' property property to each submit button, e.g.:

foreach ($result as &amp;$value) {
  ...
  $form['repo']['submit'] = [
    '#type' =&gt; 'submit',
    '#value' =&gt; $value-&gt;name,
    '#name' =&gt; $value-&gt;name,
  ];
  ...
}


In your validation and/or submit handler you can retrieve the element that triggered the form submission using $form_state-&gt;getTriggeringElement()['#name'].