yii2 why are buttons rendered outside bootstrap modal

<?php
    $yesBtn = Html::submitButton('yes', ['class' => 'btn btn-primary']);
    $noBtn = Html::submitButton('no', ['class' => 'btn btn-secondary']);

    $modal = Modal::begin([
// ...
'footer' => "$noBtn $yesBtn"
    ]);

echo "are you sure?";

    Modal::end();

    echo $modal->run();

I have the above code to render a modal, and have 2 buttons (yesBtn, noBtn) shown on it, but both buttons are rendered outside the modal too (at the bottom of the page, even before clicking the modal’s toggleButton), where i don’t want them.

Why does adding the buttons to the footer render them outside the modal?
Is there a better way to achieve what i’m trying to do?