dinamis kegiatan

parent 7f9aef4d
...@@ -88,4 +88,13 @@ public function store(Request $request) { ...@@ -88,4 +88,13 @@ public function store(Request $request) {
} }
} }
public function addFormKegiatan(Request $request)
{
$data['kegiatan'] = Kegiatan::get();
$data['konferensi'] = Konferensi::get();
$data['i'] = $request->i;
return view('form_kegiatan', $data);
}
} }
<div class="col-md-12" id="kegiatan-{{ $i }}">
<div class="card">
<div class="card-body">
<div class="form-group" id = "list-kegiatan" @if ($errors->has('thematic_workshop')) has-error @endif>
<label>Kegiatan</label>
@foreach ($kegiatan as $keg)
<div class="form-check">
<input class="form-check-input" type="radio" id="kegiatan" name="kegiatan{{ $i }}[]" value="{{ $keg->id }}">
<label class="form-check-label" for="{{ $keg->nama }}">{{ $keg->nama }}</label>
</div>
@endforeach
</div>
<div class="form-group" id="grup-konferensi" @if ($errors->has('profil')) has-error @endif>
<label>Konferensi</label>
<select class="form-control" id="konferensi" name="konferensi[]" required="true" placeholder="">
<option value="" selected>- Pilih -</option>
@foreach ($konferensi as $kon)
<option onchange="cek(this.value)" value="{{ $kon->id }}">{{ $kon->nama }}</option>
@endforeach
</select>
@if ($errors->has('konferensi'))
<label id="login-error" class="error" for="konferensi" style="color: red">{{$errors->first('konferensi')}}</label>
@endif
</div>
</div>
<button class="btn btn-danger" type="button" onclick="hapusKegiatan('kegiatan-{{ $i }}')">hapus</button>
</div>
</div>
...@@ -108,40 +108,15 @@ ...@@ -108,40 +108,15 @@
</div> </div>
</div> </div>
<div class="col-12 col-md-4 col-lg-4"> <div class="col-12 col-md-4 col-lg-4">
<div class="card"> <div class="row" id="parent-kegiatan">
<div class="card-body"> {{ view('form_kegiatan', [
<div class="form-group" id = "list-kegiatan" @if ($errors->has('thematic_workshop')) has-error @endif> 'kegiatan' => $kegiatan,
<label>Kegiatan</label> 'konferensi' => $konferensi,
@foreach ($kegiatan as $keg) 'i' => 0
<div class="form-check"> ]) }}
<input class="form-check-input" type="radio" id="kegiatan" name="kegiatan" value="{{ $keg->id }}"> </div>
<label class="form-check-label" for="{{ $keg->nama }}">{{ $keg->nama }}</label> <div>
</div> <button type="button" class="btn btn-primary" onclick="tambahKegiatan()">Tambah kegiatan</button>
@endforeach
{{-- <select class="form-control" id="kegiatan" name="kegiatan" required="true" placeholder="kegiatan">
<option value="" selected>- pilih -</option>
@foreach ($kegiatan as $keg)
<option value="{{ $keg->id }}">{{ $keg->nama }}</option>
@endforeach
</select>
@if ($errors->has('kegiatan'))
<label id="login-error" class="error" for="kegiatan" style="color: red">{{$errors->first('kegiatan')}}</label>
@endif --}}
</div>
<div class="form-group" id="grup-konferensi" @if ($errors->has('profil')) has-error @endif>
<label>Konferensi</label>
<select class="form-control" id="konferensi" name="konferensi" required="true" placeholder="">
<option value="" selected>- Pilih -</option>
@foreach ($konferensi as $kon)
<option onchange="cek(this.value)" value="{{ $kon->id }}">{{ $kon->nama }}</option>
@endforeach
</select>
@if ($errors->has('konferensi'))
<label id="login-error" class="error" for="konferensi" style="color: red">{{$errors->first('konferensi')}}</label>
@endif
</div>
</div>
</div> </div>
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
...@@ -194,4 +169,31 @@ function cek(var){ ...@@ -194,4 +169,31 @@ function cek(var){
} }
} }
</script> </script>
<script>
var i = 1;
function tambahKegiatan(){
let token = '{{ csrf_token() }}';
if (i === undefined) {
i = 1;
}
var request = $.ajax({
url: '{{ route('registrasi.form-kegiatan.add') }}',
type:'POST',
dataType: 'html',
data: {_token:token, i:i},
success: function (result) {
$('#parent-kegiatan').append(result);
}
});
i++;
}
function hapusKegiatan(id){
$('#'+id).remove();
}
</script>
@endpush @endpush
...@@ -38,3 +38,5 @@ ...@@ -38,3 +38,5 @@
Route::get('/peserta', [AdminController::class, 'index_peserta'])->name('admin.index_peserta'); Route::get('/peserta', [AdminController::class, 'index_peserta'])->name('admin.index_peserta');
Route::get('/download_peserta', [AdminController::class, 'download_peserta'])->name('admin.download_peserta'); Route::get('/download_peserta', [AdminController::class, 'download_peserta'])->name('admin.download_peserta');
Route::get('/delete_peserta/{id}', [AdminController::class, 'delete_peserta'])->name('admin.delete_peserta'); Route::get('/delete_peserta/{id}', [AdminController::class, 'delete_peserta'])->name('admin.delete_peserta');
Route::post('/add-kegiatan', [RegistrasiController::class, 'addFormKegiatan'])->name('registrasi.form-kegiatan.add');
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment