<?= $this->include('/Styles/header'); ?>

<main class="p-6">
  <div class="bg-white shadow rounded-lg p-6">
    <h2 class="text-2xl font-bold mb-4">Edit Apartment</h2>

    <form action="<?= site_url('apartment/update/'.$apartment['id']) ?>" method="post" class="grid grid-cols-2 gap-4">
      <?= csrf_field() ?>

      <div>
        <label class="block font-semibold">Apartment Name</label>
        <input type="text" name="apartName" value="<?= $apartment['apartName'] ?>" class="w-full border p-2 rounded" required>
      </div>

      <div class="col-span-2">
        <label class="block font-semibold">Apartment Address</label>
        <textarea name="apartAddress" class="w-full border p-2 rounded"><?= $apartment['apartAdress'] ?></textarea>
      </div>

      <div>
        <label class="block font-semibold">Created By</label>
        <input type="text" name="createdby" value="<?= $apartment['createdby'] ?>" class="w-full border p-2 rounded" required>
      </div>

      <div class="col-span-2">
        <button class="bg-green-600 text-white px-4 py-2 rounded hover:bg-green-700">Update</button>
        <a href="<?= site_url('apartment') ?>" class="bg-gray-500 text-white px-4 py-2 rounded hover:bg-gray-600">Cancel</a>
      </div>
    </form>
  </div>
</main>

<?= $this->include('/Styles/footer'); ?>
