<div class="row mb-3">
    <label for="email" class="form-label ol-form-label col-sm-2 col-form-label">{{ get_phrase('Email') }}<span class="text-danger ms-1">*</span></label>
    <div class="col-sm-8">
        <input type="email" name="email" class="form-control ol-form-control" id="email" @isset($student->email) value="{{ $student->email }}" @else value="{{ old('email') }}" @endisset required>
    </div>
</div>
<div class="row mb-3">
    <div class="col-sm-8 offset-sm-2">
        <input type="hidden" name="email_verified" value="1" id="email_verified_value">
        <div class="form-check">
            <input type="checkbox" class="form-check-input" id="email_verified_checkbox" name="email_verified" value="1" checked>
            <label class="form-check-label" for="email_verified_checkbox">{{ get_phrase('Mark email as verified') }}</label>
        </div>
    </div>
</div>

@if (!isset($student->email))
    <div class="row mb-3">
        <label for="password" class="form-label ol-form-label col-sm-2 col-form-label">{{ get_phrase('Password') }}<span class="text-danger ms-1">*</span></label>
        <div class="col-sm-8">
            <input type="password" name="password" class="form-control ol-form-control" id="password">
        </div>
    </div>
@endisset


<script>
    // Get the checkbox and the hidden input
    const checkbox = document.getElementById('email_verified_checkbox');
    const hiddenInput = document.getElementById('email_verified_value');

    // Update hidden input value when the checkbox is toggled
    checkbox.addEventListener('change', function() {
        if (checkbox.checked) {
            hiddenInput.value = '1';  // Checked, set value to 1
        } else {
            hiddenInput.value = '0';  // Unchecked, set value to 0
        }
    });
</script>
