<h2 class="page-title">Crear Tipo de Grupo</h2>
<p class="text-muted">Ingrese los datos del tipo de grupo en el formulario.</p>
<div class="row">
    <div class="col-md-12">
        <div class="card shadow mb-4">
            <div class="card-header">
                <strong class="card-title">Formulario</strong>
            </div>
            <div class="card-body">
                <form action="<?= BASE_ACTION ?>grouptypes" method="POST">
                    <div class="form-group">
                        <label for="abbreviation">Abreviación</label>
                        <input type="text" name="abbreviation" class="form-control" id="abbreviation" required>
                    </div>
                    <div class="form-group">
                        <label for="description">Descripción</label>
                        <textarea class="form-control" name="description" id="description" rows="4" required></textarea>
                    </div>
                    <div class="d-flex justify-content-start">
                        <a href="<?= BASE_HREF ?>grouptypes" class="btn btn-secondary mr-2">Cancelar</a>
                        <button type="submit" class="btn btn-primary">Guardar</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<script>
    document.addEventListener("DOMContentLoaded", function() {
        document.querySelectorAll("input[required], select[required], textarea[required]").forEach(function (input) {
            let label = document.querySelector(`label[for="${input.id}"]`);
            if (label && !label.innerHTML.includes("*")) {
                label.innerHTML += ' <span class="text-danger">*</span>';
            }
        });
    });
</script>

<script>
    document.getElementById('abbreviation').addEventListener('input', function (event) {
        event.target.value = event.target.value.toUpperCase();
    });
    document.getElementById('description').addEventListener('input', function (event) {
        event.target.value = event.target.value.toUpperCase();
    });
</script>