asantibanez/laravel-blade-sortable

Submit droped items (in order)

Closed this issue ยท 3 comments

Hello,

How to store/submit droped items (in order)?

DRAG FROM:

	<x-laravel-blade-sortable::sortable group="orders">
	   @foreach($orders as $order)
	      <x-laravel-blade-sortable::sortable-item as="div" sort-key="{{ $order->id }}" class="bg-theme-gray-500 my-1 px-5 py-5 text-white">{{ $order->id }}</x-laravel-blade-sortable::sortable-item>
	   @endforeach
	</x-laravel-blade-sortable::sortable>

DROPED IN:

<form method="POST" action="{{ route('selected_orders.update', $workday->id) }}" class="py-6 px-10">
	@csrf
	@method('PATCH')
	<x-laravel-blade-sortable::sortable group="orders" name="sort_order">
          <!--- DROP ZONE --> 
	</x-laravel-blade-sortable::sortable>

	<button type="submit">Submit</button>
</form>

Fixed by adding a hidden input in the main loop. Inputs are not created automatically after a drop in the drop-zone

<input name="selection[]" type="hidden" value="{{$order->id}}">

Hi @WL1981

I'll check this one. It makes sense to be able to submit both droppable containers. ๐Ÿ‘

Hey @WL1981

Check out v1.1.0.

Just add a name prop to each <x-laravel-blade-sortable::sortable> and you get those hidden inputs with the order ๐Ÿ‘Œ