Cakephp 3.6 - 选择2和模态

I have a little problem with the select2 and a modal. I inserted a select input with multiple=true inside a modal but this is the result. First screen.

First of all, the input is very small, and as I add the students it widens (I would prefer it to be a predefined dimension.) The second problem is that if I add students, the list of students goes out behind the modal as you can see on this screen.

How could I solve these two problems? This is my lists of Students in StudentsController.php:

$students = $this->Students->find('list', ['limit' => 200]);

And this is my input:

<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
    <div class="modal-content">
        <div class="modal-header">
            <h5 class="modal-title" id="exampleModalLabel">Add student</h5>
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
            </button>
        </div>
        <div class="modal-body">

            <?= $this->Form->create(null, ['url' => ['controller' => 'Lessons', 'action' => 'addpresences', $lesson->id]]); ?>

            <div class="form-group">
            <?= $this->Form->control('students_id', [
                'type' => 'select', 
                'multiple' => true, 
                'options' => $students, 
                'hiddenField' => false,
                'id' => 'students_id',
                'class' => 'form-control',
                'label' => false
                ]); 
            ?>
            </div>

        </div>
        <div class="modal-footer">
            <?= $this->Form->button('Zapisz', ['class' => 'btn btn-primary']) ?>
            <?= $this->Form->end() ?>
        </div>
    </div>
</div>

EDIT 1: I resolve the first problem just with adding width: '100%' to

$('#students_id').select2({
    tag: true,
    multiple: 'multiple',
    width: '100%'
});

EDIT 2: I resolve the second problem too: Just add dropdownParent: $('#myModal')

$('#students_id').select2({
    tag: true,
    multiple: 'multiple',
    width: '100%',
    dropdownParent: $('#exampleModal')
});