use of EditAction in a foreach loop loads all the forms

I am using a Blade template that iterates over elements in a loop. For each element, I load a Livewire component that returns an EditAction allowing the element to be edited. So, I have this in my Blade template: blade @foreach ($sejours as $sejour) <livewire:edit-sejour-commande :sejourscommande="$sejour" wire:key="edit-sejour-commande-{{$sejour->id}}-{{ now()->timestamp }}" /> @endforeach In the Livewire component, I return the form using EditAction like this: php Copier le code public function editAction(): Action { return EditAction::make() ->record($this->sejourscommande) ->form(function (Form $form) { return $form->schema( SejourCommandeForm::schema(), ); }) ->using(function (Model $record, array $data): Model { return $this->handleSejourscommandeUpdate($record, $data); // Call the trait method }) ->slideOver(); } Everything works fine and functions as expected. The issue is that if I display many elements on the page, it loads as many forms and Livewire components, which could cause problems. So, I wanted to know if there's a way to only load the EditAction button initially and load the form only when the button is clicked.
1 Reply
toeknee
toeknee3mo ago
Not really, the form is loaded as part of the button on mount so all fields are loaded accordingly... Not sure how you would achieve that tbh, unless you loops through loaded buttons which then load the action and auto-triggered it in theory could work
Want results from more Discord servers?
Add your server