At https://docs.moodle.org/dev/lib/formslib.php_Form_Definition#addGroup the addGroup doc says:
"A 'group' in formslib is just a group of elements that will have a label and will be included on one line.
For example typical code to include a submit and cancel button on the same line :
$buttonarray =& $mform->createElement('submit', 'submitbutton', get_string('savechanges'));
$buttonarray =& $mform->createElement('submit', 'cancel', get_string('cancel'));
$mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
You use the same arguments for createElement as you do for addElement. Any label for the element in the third argument is normally ignored (but not in the case of the submit buttons above where the third argument is not for a label but is the text for the button). "
Why is the label ignored? I do need it in that case. Any workaround?