<?php $__env->startSection('content'); ?>
<div class="container mt-4">
  <h2>Tambah Jadwal Bel</h2>

  <form action="<?php echo e(route('jadwal-bel.store')); ?>" method="POST" enctype="multipart/form-data">
    <?php echo csrf_field(); ?>
    <div class="form-group">
      <label for="hari">Hari</label>
      
      <input class=" form-control" id="tagInput" name="hari" placeholder="Masukkan hari lalu Enter" />
    </div>

    <div class="form-group mt-2">
      <label for="jam">Jam</label>
      <input type="time" name="jam" class="form-control" required>
    </div>

    <div class="form-group">
      <label for="jenis">Keterangan</label>
      <select name="jenis" class="form-control">
        <option value="reguler">Reguler</option>
        <option value="ujian">Ujian</option>
      </select>
    </div>

    <div class="form-group mt-2">
      <label for="keterangan">Keterangan</label>
      <input type="text" name="keterangan" class="form-control">
    </div>

    <div class="form-group mt-2">
      <label for="file_suara">File Suara</label>
      <input type="file" name="file_suara" class="form-control" placeholder="Contoh: bel_masuk.mp3">
    </div>

    <button class="btn btn-primary mt-3">Simpan</button>
    <a href="<?php echo e(route('jadwal-bel.index')); ?>" class="btn btn-secondary mt-3">Kembali</a>
  </form>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>
<script>
  document.addEventListener('DOMContentLoaded', function () {
    const input = document.querySelector('#tagInput');

    // Cegah error jika input tidak ditemukan
    if (!input) {
      console.warn("Tagify input element not found!");
      return;
    }

    // Inisialisasi Tagify
    const tagify = new Tagify(input, {
      whitelist: ["Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu", "Minggu"],
      dropdown: {
        enabled: 0
      }
    });

    // Saat form akan disubmit, ubah nilai menjadi string "Senin, Selasa"
    const form = input.closest('form');
    if (form) {
      form.addEventListener('submit', function () {
        const selected = tagify.value.map(item => item.value); // ambil array nilai
        input.value = selected.join(', '); // ubah ke string agar masuk ke DB
      });
    }
  });
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /var/www/html/belsekolah/resources/views/jadwal_bel/create.blade.php ENDPATH**/ ?>