Add conditional custom field input types
Enhanced the handling of custom fields by conditionally adding input types like text, number, date, and textarea based on the field's type. Also, added missing placeholders to input elements to improve usability.
This commit is contained in:
@@ -176,6 +176,27 @@
|
||||
<input class="input" type="text" name="custom_field[][$detail->jenisLegalitasJaminan->custom_field]" value="{{ $custom_field[$detail->jenisLegalitasJaminan->custom_field] }}">
|
||||
</div>
|
||||
</div>
|
||||
@else
|
||||
@if($detail->jenisLegalitasJaminan->custom_field)
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56 capitalize">
|
||||
{{ str_replace('_',' ',$detail->jenisLegalitasJaminan->custom_field) }}
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
@if($detail->jenisLegalitasJaminan->custom_field_type === "text")
|
||||
<input class="input" type="text" name="custom_field[][{{$detail->jenisLegalitasJaminan->custom_field}}]" placeholder="... M2">
|
||||
@elseif($detail->jenisLegalitasJaminan->custom_field_type === "number")
|
||||
<input class="input" type="number" name="custom_field[][{{$detail->jenisLegalitasJaminan->custom_field}}]" placeholder="... M2">
|
||||
@elseif($detail->jenisLegalitasJaminan->custom_field_type === "date")
|
||||
<input class="input" type="date" name="custom_field[][{{$detail->jenisLegalitasJaminan->custom_field}}]" placeholder="... M2">
|
||||
@elseif($detail->jenisLegalitasJaminan->custom_field_type === "textarea")
|
||||
<textarea class="textarea" rows="3" name="custom_field[][{{$detail->jenisLegalitasJaminan->custom_field}}]" placeholder="... M2"></textarea>
|
||||
@else
|
||||
<input class="input" type="text" name="custom_field[][{{$detail->jenisLegalitasJaminan->custom_field}}]" placeholder="... M2">
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
@endif
|
||||
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
@@ -221,15 +242,15 @@
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
@if($item->custom_field_type === "text")
|
||||
<input class="input" type="text" name="custom_field[][{{$item->custom_field}}]">
|
||||
<input class="input" type="text" name="custom_field[][{{$item->custom_field}}]" placeholder="... M2">
|
||||
@elseif($item->custom_field_type === "number")
|
||||
<input class="input" type="number" name="custom_field[][{{$item->custom_field}}]">
|
||||
<input class="input" type="number" name="custom_field[][{{$item->custom_field}}]" placeholder="... M2">
|
||||
@elseif($item->custom_field_type === "date")
|
||||
<input class="input" type="date" name="custom_field[][{{$item->custom_field}}]">
|
||||
<input class="input" type="date" name="custom_field[][{{$item->custom_field}}]" placeholder="... M2">
|
||||
@elseif($item->custom_field_type === "textarea")
|
||||
<textarea class="textarea" rows="3" name="custom_field[][{{$item->custom_field}}]"></textarea>
|
||||
<textarea class="textarea" rows="3" name="custom_field[][{{$item->custom_field}}]" placeholder="... M2"></textarea>
|
||||
@else
|
||||
<input class="input" type="text" name="custom_field[][{{$item->custom_field}}]">
|
||||
<input class="input" type="text" name="custom_field[][{{$item->custom_field}}]" placeholder="... M2">
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@@ -246,9 +267,7 @@
|
||||
@php $n++; @endphp
|
||||
@endforeach
|
||||
@else
|
||||
<div id="doctainer" class="grid gap-5">
|
||||
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
@@ -370,13 +389,13 @@
|
||||
@push('scripts')
|
||||
{{--Pemilik Jaminan--}}
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
const namaSertifikatDiv = document.getElementById("nama_sertifikat");
|
||||
|
||||
// Function to add delete event listeners to existing buttons
|
||||
function addDeleteListeners() {
|
||||
document.querySelectorAll(".delete-button").forEach(button => {
|
||||
button.addEventListener("click", function() {
|
||||
button.addEventListener("click", function () {
|
||||
this.closest(".flex.items-baseline.flex-wrap.lg\\:flex-nowrap.gap-2\\.5.mb-5").remove();
|
||||
});
|
||||
});
|
||||
@@ -385,7 +404,7 @@
|
||||
// Add delete listeners to existing buttons
|
||||
addDeleteListeners();
|
||||
|
||||
document.getElementById("tambah_sertifikat").addEventListener("click", function() {
|
||||
document.getElementById("tambah_sertifikat").addEventListener("click", function () {
|
||||
const newDiv = document.createElement("div");
|
||||
newDiv.className = "flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 mb-5";
|
||||
newDiv.innerHTML = `
|
||||
|
||||
Reference in New Issue
Block a user