Auth1Specialist
Auth1Specialist
FFilament
Created by Auth1Specialist on 2/17/2025 in #❓┊help
Duplicating record before using inside of editOptionForm.
Hi all, I would like to duplicate a record before opening it in the modal and editing it using the editOptionForm. I have been playing around with all the various lifecyclehooks of the editOptionAction -> $action, but without any success at the moment. I can't seem to find how to pass the newly created record to the Component of the Edit action / form? Current code (not working):
->editOptionForm(FinancialCalculation::form())
->editOptionAction(function(Forms\Components\Actions\Action $action, Forms\Components\Select $component, $livewire) {
$form_data = $component->getSelectedRecord()?->attributesToArray();

if (is_array($form_data)) {
$form_data['is_hidden'] = 1;
$form_data['is_disabled'] = 1;

$action->fillForm(function(Forms\Components\Select $component) use ($form_data) {
$record = $component->getSelectedRecord()?->replicate();
return $record->attributesToArray();
});
}

return $action->slideOver();
})
->editOptionForm(FinancialCalculation::form())
->editOptionAction(function(Forms\Components\Actions\Action $action, Forms\Components\Select $component, $livewire) {
$form_data = $component->getSelectedRecord()?->attributesToArray();

if (is_array($form_data)) {
$form_data['is_hidden'] = 1;
$form_data['is_disabled'] = 1;

$action->fillForm(function(Forms\Components\Select $component) use ($form_data) {
$record = $component->getSelectedRecord()?->replicate();
return $record->attributesToArray();
});
}

return $action->slideOver();
})
Anyone have any ideas? Thanks!
5 replies
FFilament
Created by Auth1Specialist on 1/22/2025 in #❓┊help
Triggering editaction on Stat click
Hi all, I have been trying to add a click event to trigger a "editAction". The event gets dispatched, but the modal (/slideover) does not show. When I trigger the action directly, the modal does show. This is how I am trying to achieve this:
return [
Stat::make($this->widget->name, reset($stats))
->description(new HtmlString($this->widget->description))
->extraAttributes([
'class' => 'cursor-pointer widget-edit-hover transition-all duration-300 ease-in-out',
'wire:click' => "\$dispatch('widget-edit', { id: " . $this->widget->id . " })",
])
->descriptionIcon('heroicon-m-arrow-trending-up')
->color($this->widget->color)
];
return [
Stat::make($this->widget->name, reset($stats))
->description(new HtmlString($this->widget->description))
->extraAttributes([
'class' => 'cursor-pointer widget-edit-hover transition-all duration-300 ease-in-out',
'wire:click' => "\$dispatch('widget-edit', { id: " . $this->widget->id . " })",
])
->descriptionIcon('heroicon-m-arrow-trending-up')
->color($this->widget->color)
];
#[On('widget-edit')]
public function editDashboardAction(string $id): EditAction
{
$widget = Widget::query()->find($id);
ray($widget);
return EditAction::make('editDashboard')
->model(Widget::class)
->record($widget)
->form(Widget::form())
->after(function () {
$this->dispatch('$refresh');
})
->slideOver();
}
#[On('widget-edit')]
public function editDashboardAction(string $id): EditAction
{
$widget = Widget::query()->find($id);
ray($widget);
return EditAction::make('editDashboard')
->model(Widget::class)
->record($widget)
->form(Widget::form())
->after(function () {
$this->dispatch('$refresh');
})
->slideOver();
}
- I have confirmed the function gets called on Click - I have confirmed the modals code itself is loaded on the page Thanks for the help!
5 replies
FFilament
Created by Auth1Specialist on 12/14/2024 in #❓┊help
Repeater optimistic UI with livewire
Hi all, Does anyone have any pointers on how to implement an optimistic UI using the Livewire repeater? I was thinking of using alpine to do so, so I was wondering if anybody already attempted something similar / has any pointers on this. Thanks!
7 replies