Kiran Timsina
Tab Badge not updating
I have a tab in ListBlogPosts where i have two tabs with badge that has count.
I want the count to be dyanamically updated based on my active filter. Sadly, the count does not update. Probably the code to generate the badge does not run on filter change. Is there a way to achieve it?
1 replies
Do not show rows with computed data
I have a table with two columns, both are computed values based on some complex queries. Now i need a way to not show these rows if certain computed value which is shown in the table is 0. Is there a way to do this ?
For example in my screenshot, i do not want to show those rows where 0.0 is the only value.
2 replies
Validation not working when state change occurs
I am trying to use regex validation with my slug TextInput. The value of this field is also automatically updated based on name. Now the issue is when i change the slug and save, it validates just fine. But if I change the nam, the slug also updates and even if it is all right, I get validation error.
I am inclining towards a bug in the core that's causing this. If anyone have faced similar issue and figured a workaround, please help me with this.
Thank You
2 replies
Updating data of getNavigationBadge()
Is there a way to trigger updating the value returned by getNavigationBadge(). For example, I have a number shown which changes on deleting a row. And that number should now decrease by 1. It does when refreshed, but is there a way to do it without refresing the whole page?
2 replies
A way to make lazy search ?
I have a db with hundred thousand products. the in-built search freezes the table as it searches on type. I made a text input to make implement the search but it also searches on every letter typed. Is there a way to make the search happen only when the the focus changes or enter is pressed?
4 replies
Resize Images after Upload
I have many models that have "image" column. Each image is uploaded using the FileUpload of filament, but I need to resize it to 5 different sizes. I couldn't use Spatie's package as I have "image" field in many models instead of creating one "media" table and creating all images there.
Right now the solution I am using is writing code in CreateProduct and EditProduct to handle image resize (and deletion of resized images)
Here is an example, which works, but doing this for other 50 models would require duplicating this code 50 times. What else can i do to make sure image resize is handled by a single code base. I could think of probably through an event listener, or a middleware or confuguring FileUpload to do it for all. But I'm unaware how I can achieve this in filament.
27 replies
Custom Reports using Filament Tables
I am trying to create views for reports. And in these view I am trying to load filament table with the report data.
I tried creating a filament-page and load table but not able to do so due to the error Property [$table] not found on component:...
26 replies
Help with reactive view
I created a basic greeting card maker that uses two models Design (for the content) and Template (for design and structure). The view is rendered from a blade file that has css and html and uses $this->record and $this->record->template for the values.
I have been trying to break the view into two parts where there is a form at one since and rendered content at other side so I can create/edit the design in realtime.
I am sure this is possible but I am not able to figure out where to begin with.
I made two livewire compoenents CardForm and CardDisplay. I moved the whole view blade to card-display. And now I'm stuck right there. Any heads up or a relevant tutorial (Which I am unable to find) would really mean a lot.
Thank You
2 replies
Help accessing parent form field value
Since I could not $get the field value when trying to access the field value I found a hack to set form variables like this:
But a much easier way would be if I could simply $get the field value from another formgroup. Does anyone have idea about this?
5 replies
Issue with non-skippable wizard when a step is hidden
Clicking the next on the 2nd step does not do anything when product_type is not cake. It works fine if it is a cake.
public static function form(Form $form): Form
{
return $form
->schema([
Wizard::make([
Wizard\Step::make('Information')
->description(fn ($context) => $context === 'create' ? 'Basic Info!' : null)
->schema([
static::getTypeFormField(),
...
])->columns(2),
Wizard\Step::make('Cake')
->description(fn ($context) => $context === 'create' ? 'Cake Details!' : null)
->schema([
static::getCakeFormField()
])->hidden(
fn (callable $get) => $get('product_type') !== 'cake'
),
Wizard\Step::make('Price')
->description(fn ($context) => $context === 'create' ? 'Price and Sale' : null)
->schema([
static::getPriceSetFormField(),
...
]),
Wizard\Step::make('SEO/Search')
->description(fn ($context) => $context === 'create' ? 'Search Related Info' : null)
->schema([
static::getMetaGroupFormField(),
]),
...
])->columnSpanFull()
->skippable(fn ($context) => $context === 'edit')
]);
}
3 replies
Can't get the colors to work
I am trying to follow the statsoverview docs and create some cards like this:
Card::make(
'Idle Bakers',
"$idleBakers"
)->color($idleBakers > 0 ? 'warning' : 'success'),
Card::make(
'Unprocessed Orders',
"$unprocessedOrders"
)->color(($idleBakers && $unprocessedOrders) ? 'danger' : (($unprocessedOrders && !$idleBakers) ? 'warning' : 'success')),
Card::make(
'Ready Orders',
"$readyOrders"
),
Card::make(
'Idle Riders',
"$idleRiders"
)->color(($readyOrders && $idleRiders) ? 'danger' : (($readyOrders && !$idleRiders) ? 'warning' : 'success')),
My tailwind.config.js, vite.config.js and postcss.config.js are as per this doc:
https://filamentphp.com/docs/2.x/admin/appearance#building-themes
Here is my AppServiceProvider
public function boot(): void
{
// Filament::serving(function () {
// // Using Vite
// Filament::registerViteTheme('resources/css/filament.css');
// });
}
I have commented the code becuase it makes the whole ui break as filament.css is not present
10 replies
Custom View Page using Filament Table Builder
I want to create a custom view page that can use Filament's Table Builder and build tables instead of using HTML/CSS . I am sure that's why FIlmanet tables is for. but I am confused about how to do it.
I have a ViewOrder.php where I have done this:
protected static string $view = 'filament.resources.orders.pages.view-order';
</x-filament::page>
html and css code here
</x-filament::page>
It is working fine but I am using html/css to manually build the page.
13 replies
How to run a query based on fields and show output in another field
This is my form :
return $form
->schema([
Group::make([
Toggle::make('has_verified_email')->reactive(),
Toggle::make('has_verified_phone')->reactive(),
Toggle::make('new_users_only')->reactive()
->afterStateUpdated(fn (Closure $set, $get, $state) => $get('new_users_only') ? $set('old_users_only', !$state) : ''),
Toggle::make('old_users_only')->reactive()
->afterStateUpdated(fn (Closure $set, $get, $state) => $get('old_users_only') ? $set('new_users_only', !$state) : ''),
Forms\Components\TextInput::make('test')->afterStateUpdated(
function (Closure $get) {
$count = User::when($get('has_verified_email'), function ($q) {
$q->whereNotNull('email_verified_at');
})->when($get('has_verified_phone'), function ($q) {
$q->whereNotNull('has_verified_phone');
})->when($get('new_users_only'), function ($q) {
$q->whereDate('created_at', '>=', now()->subMonth());
})->when($get('old_users_only'), function ($q) {
$q->whereDate('created_at', '<=', now()->subMonth());
})->count();
return "$count users selected!";
}
)
->columnSpanFull()->disabled()->disableLabel()
])->columnSpan(12)->columns(4),
I want to fill up the field 'test' with the count of users based on the other toggles set. I could set it using default but it works in first load only. I want to update the 'test' every time a toggle is changed.
Is there a way to achieve this? Thank You
4 replies