Skip to content

Commit

Permalink
Merge pull request #106 from ikhsan3adi/refactor
Browse files Browse the repository at this point in the history
refactor form variable namings
  • Loading branch information
ikhsan3adi authored Jul 15, 2024
2 parents f9ef42f + 8c8bcc1 commit abb8806
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions app/Controllers/Admin/KelasController.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function create()
'kelas' => [
'rules' => 'required|max_length[32]',
],
'idJurusan' => [
'id_jurusan' => [
'rules' => 'required|numeric',
],
])) {
Expand All @@ -99,7 +99,7 @@ public function create()

// ambil variabel POST
$kelas = $this->request->getVar('kelas');
$idJurusan = $this->request->getVar('idJurusan');
$idJurusan = $this->request->getVar('id_jurusan');

$result = $this->kelasModel->tambahKelas($kelas, $idJurusan);

Expand Down Expand Up @@ -153,7 +153,7 @@ public function update($id = null)
'kelas' => [
'rules' => 'required|max_length[32]',
],
'idJurusan' => [
'id_jurusan' => [
'rules' => 'required|numeric',
],
])) {
Expand All @@ -178,7 +178,7 @@ public function update($id = null)

// ambil variabel POST
$kelas = $this->request->getRawInputVar('kelas');
$idJurusan = $this->request->getRawInputVar('idJurusan');
$idJurusan = $this->request->getRawInputVar('id_jurusan');

$result = $this->kelasModel->update($id, [
'kelas' => $kelas,
Expand Down
10 changes: 5 additions & 5 deletions app/Views/admin/kelas/create.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@
</div>
<div class="row">
<div class="col-12">
<label for="idJurusan">Jurusan</label>
<select class="custom-select <?= $validation->getError('idJurusan') ? 'is-invalid' : ''; ?>" id="idJurusan" name="idJurusan">
<option value="">--Pilih jurusan--</option>
<label for="id_jurusan">Jurusan</label>
<select class="custom-select <?= $validation->getError('id_jurusan') ? 'is-invalid' : ''; ?>" id="id_jurusan" name="id_jurusan">
<option value="">--Pilih Jurusan--</option>
<?php foreach ($jurusan as $value) : ?>
<option value="<?= $value['id']; ?>" <?= old('idJurusan') ?? $oldInput['idJurusan'] ?? '' == $value['id'] ? 'selected' : ''; ?>>
<option value="<?= $value['id']; ?>" <?= old('id_jurusan') ?? $oldInput['id_jurusan'] ?? '' == $value['id'] ? 'selected' : ''; ?>>
<?= $value['jurusan']; ?>
</option>
<?php endforeach; ?>
</select>
<div class="invalid-feedback">
<?= $validation->getError('idJurusan'); ?>
<?= $validation->getError('id_jurusan'); ?>
</div>
</div>
</div>
Expand Down
10 changes: 5 additions & 5 deletions app/Views/admin/kelas/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@
</div>
<div class="row">
<div class="col-12">
<label for="idJurusan">Jurusan</label>
<select class="custom-select <?= $validation->getError('idJurusan') ? 'is-invalid' : ''; ?>" id="idJurusan" name="idJurusan">
<option value="">--Pilih idJurusan--</option>
<label for="id_jurusan">Jurusan</label>
<select class="custom-select <?= $validation->getError('id_jurusan') ? 'is-invalid' : ''; ?>" id="id_jurusan" name="id_jurusan">
<option value="">--Pilih Jurusan--</option>
<?php foreach ($jurusan as $value) : ?>
<option value="<?= $value['id']; ?>" <?= old('idJurusan') ?? $oldInput['idJurusan'] ?? $value['id'] == $data['id_jurusan'] ? 'selected' : ''; ?>>
<option value="<?= $value['id']; ?>" <?= old('id_jurusan') ?? $oldInput['id_jurusan'] ?? $value['id'] == $data['id_jurusan'] ? 'selected' : ''; ?>>
<?= $value['jurusan']; ?>
</option>
<?php endforeach; ?>
</select>
<div class="invalid-feedback">
<?= $validation->getError('idJurusan'); ?>
<?= $validation->getError('id_jurusan'); ?>
</div>
</div>
</div>
Expand Down

0 comments on commit abb8806

Please sign in to comment.