charlie
charlie
FFilament
Created by Nicole on 5/13/2025 in #❓┊help
How can I check for any unsaved changes in the edit form?
wire:dirty is a livewire directive: https://livewire.laravel.com/docs/wire-dirty And you should replace enabled-class with any css class you want
28 replies
FFilament
Created by Čamap on 5/13/2025 in #❓┊help
Reset only one form field into it's default state
Should work:
->afterStateUpdated(function (Set $set, $livewire) {
$set('type', $livewire->getOldFormState('data.type'));
})
->afterStateUpdated(function (Set $set, $livewire) {
$set('type', $livewire->getOldFormState('data.type'));
})
11 replies
FFilament
Created by Čamap on 5/13/2025 in #❓┊help
Reset only one form field into it's default state
->afterStateUpdated(function (Set $set) {
// reset input named "type" into it's default() state
$set('type', 'whatever you want');
})
->afterStateUpdated(function (Set $set) {
// reset input named "type" into it's default() state
$set('type', 'whatever you want');
})
11 replies
FFilament
Created by Nicole on 5/13/2025 in #❓┊help
How can I check for any unsaved changes in the edit form?
Tested and approved. I think I'll use that too! Here's how you'd use it @Nicole :
protected function getSaveFormAction(): Actions\Action
{
return Actions\Action::make('save')
->extraAttributes([
'wire:dirty.class' => 'enabled-class',
]);
}
protected function getSaveFormAction(): Actions\Action
{
return Actions\Action::make('save')
->extraAttributes([
'wire:dirty.class' => 'enabled-class',
]);
}
28 replies
FFilament
Created by Nicole on 5/13/2025 in #❓┊help
How can I check for any unsaved changes in the edit form?
(copied from vendor/filament/filament/resources/views/components/page/unsaved-data-changes-alert.blade.php)
28 replies
FFilament
Created by Nicole on 5/13/2025 in #❓┊help
How can I check for any unsaved changes in the edit form?
I think you could do that in Alpine with something like:
if (
window.jsMd5(
JSON.stringify($wire.data).replace(/\\/g, ''),
) === $wire.savedDataHash ||
$wire?.__instance?.effects?.redirect
)
if (
window.jsMd5(
JSON.stringify($wire.data).replace(/\\/g, ''),
) === $wire.savedDataHash ||
$wire?.__instance?.effects?.redirect
)
28 replies
FFilament
Created by J3R1CH0 on 5/13/2025 in #❓┊help
Won't Work the defaultItems(1) on Repeater
If you absolutely need the repeater item to show on edit page when value is null, you'll need to format the state on hydration from null to an empty array or something like that
8 replies
FFilament
Created by J3R1CH0 on 5/13/2025 in #❓┊help
Won't Work the defaultItems(1) on Repeater
Your code seems right, but it won't work when you edit record, only when you create one, because when you edit the record it will fetch repeater data from db and if it's null, the empty repeater won't show. (like Dennis said) However it should have one default empty item on create record page.
8 replies
FFilament
Created by islandnuge on 5/13/2025 in #❓┊help
How to handle the deleteAction for the file-upload field
It is the responsibility of the developer to delete these files from the disk if they are removed, as Filament is unaware if they are depended on elsewhere. One way to do this automatically is observing a model event.
From the docs here: https://filamentphp.com/docs/3.x/forms/fields/file-upload#configuring-the-storage-disk-and-directory Here is how you could do it in a table for example:
Tables\Actions\DeleteAction::make()
->after(function (YourModel $record) {
if ($record->path) {
$deleted = Storage::disk('local')->delete($record->path);
if (!$deleted) {
Notification::make()
->title('Error')
->body('An error happened when deleting the file')
->danger()
->send();
}
}
})
Tables\Actions\DeleteAction::make()
->after(function (YourModel $record) {
if ($record->path) {
$deleted = Storage::disk('local')->delete($record->path);
if (!$deleted) {
Notification::make()
->title('Error')
->body('An error happened when deleting the file')
->danger()
->send();
}
}
})
3 replies
FFilament
Created by PabloZagni on 5/5/2025 in #❓┊help
Line breaks in TextEntry
maybe something like that ?
TextEntry::make('...')
->formatStateUsing(fn($state) => nl2br($state))
->html(),
TextEntry::make('...')
->formatStateUsing(fn($state) => nl2br($state))
->html(),
4 replies
FFilament
Created by 403gtfo on 5/12/2025 in #❓┊help
CreateAction::make()->before() not being triggered.
I don't know why it doesn't work, but you could use that instead:
protected function mutateFormDataBeforeCreate(array $data): array
{
//
}
protected function mutateFormDataBeforeCreate(array $data): array
{
//
}
You'll need to add it to CreateAchievementCategory class
4 replies
FFilament
Created by __Dementor on 5/12/2025 in #❓┊help
How to change resource label dynamic
public static function getNavigationLabel(): string
{
//
}
public static function getNavigationLabel(): string
{
//
}
4 replies
FFilament
Created by SnaggyDainc on 5/12/2025 in #❓┊help
table row background color & clear all filters button
you may need a custom theme if you use tailwind classes that haven't been used yet by filament
9 replies
FFilament
Created by SnaggyDainc on 5/12/2025 in #❓┊help
table row background color & clear all filters button
ok. I mean if you don't sort, you can do it with simple CSS but only for the first 4.
/* First 4 are green */
.fi-ta-row:nth-child(1), .fi-ta-row:nth-child(2), .fi-ta-row:nth-child(3), .fi-ta-row:nth-child(4) {
background-color: rgba(34, 197, 94, 0.3);
}
/* First 4 are green */
.fi-ta-row:nth-child(1), .fi-ta-row:nth-child(2), .fi-ta-row:nth-child(3), .fi-ta-row:nth-child(4) {
background-color: rgba(34, 197, 94, 0.3);
}
But for the last four it's not possible in CSS because of pagination. However, you could do that on php side with recordClasses :
->recordClasses(fn(YourModel $record) => match (true) {
$record->isInTop4() => 'border-s-2 !border-s-green-600 !dark:border-s-green-300',
$record->isInBottom4() => 'border-s-2 !border-s-red-600 !dark:border-s-red-300',
default => '',
})
->recordClasses(fn(YourModel $record) => match (true) {
$record->isInTop4() => 'border-s-2 !border-s-green-600 !dark:border-s-green-300',
$record->isInBottom4() => 'border-s-2 !border-s-red-600 !dark:border-s-red-300',
default => '',
})
9 replies
FFilament
Created by SnaggyDainc on 5/12/2025 in #❓┊help
table row background color & clear all filters button
the first 4 no matter how they're sorted?
9 replies
FFilament
Created by Nicole on 5/12/2025 in #❓┊help
header action opens a create modal, followed by a confirmation modal
use $data
13 replies
FFilament
Created by Nicole on 5/12/2025 in #❓┊help
header action opens a create modal, followed by a confirmation modal
I don't think so
13 replies
FFilament
Created by Nicole on 5/12/2025 in #❓┊help
header action opens a create modal, followed by a confirmation modal
or use wire:confirm from native Livewire
13 replies
FFilament
Created by Nicole on 5/12/2025 in #❓┊help
header action opens a create modal, followed by a confirmation modal
13 replies
FFilament
Created by charlie on 5/12/2025 in #❓┊help
Auto set minutes to 00 when an hour is set with native TimePicker
According to this SO comment, this is not possible because the field doesn't even have a value when it's partially filled. https://stackoverflow.com/a/58669146
6 replies