I found what I was looking for with registerNoSubmitButton() which does exactly what I was after.
General developer forum
Remove element button for repeat_elements
Hi, David Poly.
I'm trying to do something very similar to what you''ve done.
How did you implemented it ?
An example of my code :
$this->questions = $mform->createElement('button', 'deletequestion', get_string('question_remove', 'mod_mymod'), 0);
-- end Code
I just want to remove 'question's created with the 'Add' button implemented by 'repeat_elements' method.