ARTICLE AD BOX
I’m working on a Laravel 12 modular project.
I have a tree view of locations, and inside the “box” type location I display archives.
Each archive has a “Pindahkan” (Move) button that opens a modal.
Inside the modal, I submit a form using PUT to update the archive’s location.
The form action is set dynamically using JavaScript based on the archive slug.
Route::put('/admin/archives/{archive}/move-location', [ArchiveController::class, 'moveLocation']) ->name('arsip-desa.admin.archives.move-location'); document.addEventListener('click', (e) => { const btn = e.target.closest('.js-move-archive'); if (!btn) return; const archiveSlug = btn.dataset.archiveSlug; const base = @json(route( arsip_desa_meta('kebab').'.admin.archives.move-location', ['archive' => '___SLUG___'] )); moveForm.action = base.replace('___SLUG___', archiveSlug); });Blade
<form id="move-archive-form" method="POST" action="#" class="space-y-4"> @csrf @method('PUT') <x-form.input-select label="Location (Leaf)" name="location_id" :options="$leafLocationOptions ?? []" rules="required" size="sm" :validate-client="false" /> </form>