Filament

F

Filament

Join the community to ask questions about Filament and get answers from other members.

Join Server

Community questions

Ssikegush9/22/2023

RenderHook bottom of the Menu

Hey,

Im was trying to put a logo in the bottom of the sidebar.

Filament::registerRenderHook(
                'sidebar.end',
                fn (): View => view('filament.logoIPT.logo'),
            );


but the code above renders it just after the last menu item, not on the bottom...

any work around this? Thanks
Solution:
I think I used CSS and added margin to the bottom of the sidebar and positioned the element at the bottom of the container with a position absolute
Message Not Public
Sign In & Join Server To View
Ccvc_web9/21/2023

undefined variable $activeTab in listPage Class

I am getting a error undefined variable $activeTab on the list page
```<?php

namespace App\Filament\Resources\BookingResource\Pages;

use App\Filament\Resources\BookingResource;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;
use Filament\Resources\Pages\ListRecords\Tab;
use Illuminate\Database\Eloquent\Builder;

class ListBookings extends ListRecords
{
//public ?string $activeTab = 'active';
protected static string $resource = BookingResource::class;

p...
Solution:
fixed in .58
Message Not Public
Sign In & Join Server To View
Mmark_chaney9/21/2023

SelectFilter hidden()

So I have this SelectFilter that I want hidden based on $activeTab that is set by getTabs(). I have ```php
SelectFilter::make('status')
->label('Status')
->hidden(function () {
ray($this->activeTab)->label('status');

return in_array($this->activeTab, ['all', 'active', 'inactive']);
})
->options([
'Active' => 'Active',
'Prospect' => auth()->user()->isInternal() ? 'Prospect' : 'Draft',
'Inactive' => 'Inactive',
])->query(function (Builde...
Solution:
@archilex this is working great. thanks!
->hidden(function () {
    $tabsToHideFilter = ['active', 'inactive', 'draft'];
    $shouldHideFilter = in_array($this->activeTab, $tabsToHideFilter);

    if ($shouldHideFilter) {
        $this->tableFilters['status'] = null;
    }

    return $shouldHideFilter;
})
public function updatedActiveTab(): void
{
    unset($this->cachedForms['tableFiltersForm']);
    $this->resetPage();
}
Jjohan929/21/2023

assertPageActionHidden testing helper gone?

Is the assertPageActionHidden testing helper gone?
Solution:
Looks like it is now working with assertActionHidden
Jjohan929/21/2023

formatStateUsing not called if value is null

                Tables\Columns\TextColumn::make('cancelled_at')
                    ->label('Cancelled')
                    ->formatStateUsing(fn (?string $state) => $state ? 'Yes' : 'No')
                    ->colors([
                        'success' => static fn (?string $state): bool => empty($state),
                        'danger' => static fn (?string $state): bool => !empty($state),
                    ]),


This does echo "Yes" but if cancelled_at is null it wont show "...
Solution:
Use getStateUsing() instead
Message Not Public
Sign In & Join Server To View
Ttorriv9/21/2023

Full screen widget

Is it possible to toggle a widget (chart widget to be specific) to show in full screen? I haven't found anything about it.
I was first thinking of adding an action in the header of the widget, but that doesn't seem to be possible without making a custom widget. am i right?
Solution:
ahh, would be a custom widget as well
Message Not Public
Sign In & Join Server To View
Tthijmenkort9/21/2023

Different app name for each panel

Filament uses the application name for in the title. Is this something that i can override to make this customizable for every panel?
Solution:
->brandName('') ?
Message Not Public
Sign In & Join Server To View
Mm.mohamed9/21/2023

How to test a custom action?

In v2 this used to work
livewire(EditOrder::class, [
        $order->getKey(),
    ])
        ->callPageAction('return');


but in V3 it gives
Method Illuminate\Http\Response::callPageAction does not exist.

I changed callPageAction to runAction and now I'm getting
Unable to call component method. Public method [return] not found on component
Solution:
Try callAction()
Message Not Public
Sign In & Join Server To View
Ddanielbehrendt9/21/2023

Make single row not clickable

Is there a way to make only one specific row not clickable?
Solution:
found out that it only seems to work when using getTableRecordUrlUsing() function
Ffinn.smith9/21/2023

Selecting only a year

Does Filament's datepicker offer an option for only years being able to be selected?
Is this something that's better to do that with a different input type? My database column is a datatype of year(4).
My current solution is:
TextInput::make('redacted_date_field')
  ->numeric()
  ->minValue(1900)
  ->maxValue(2100)
  ->hidden(fn(Get $get): bool => $get('redacted_bool_field') === false),
Solution:
I would do like this Forms\Components\Select::make('year')->options(array_combine(range(2100, 1900), range(2100, 1900)))
Ttieme22809/21/2023

Relation manager (Hide Table data from table record)

Hi All,

I use the table of the (in my case) ProjectResource.
In that table i want to hide one or 2 columns in the relation manager table.

Example of table.
The first Stack::make (with company.companyname and contact.full_name) needs to be vissible on the "ProjectResource" but Hidden in RalationsshipManager

`
return $table
->columns([
Split::make([
Stack::make([
TextColumn::make('company.companyname')...
Ttieme22809/21/2023

Relation managers (Hide on edit page)

Hi All,

Maybe I looked over it, but how can i hide the Relation tables on the edit page of the parent record?
It needs to be vissble only on the view of the parent.

Thanks.
Solution:
On the EditRecord Page add:
    protected function getRelationManagers(): array
    {
        return [];
    }

Does that work
Message Not Public
Sign In & Join Server To View
Jjals659/21/2023

Custom Page in menu without resource

It's possible to create a custom simple page without a resource, and add it to dashboard menu?
Solution:
Yes it is possible, depens on what you need.
You can add a page by following this documentation page : https://filamentphp.com/docs/3.x/panels/pages
Vvalpuia9/21/2023

Register assets per panel?

How can I register CSS per panel, all I can find is this https://filamentphp.com/docs/3.x/support/assets but this change all panel
Vvalpuia9/21/2023

render hook per panels?

How to set render hook per panels?
Solution:
Message Not Public
Sign In & Join Server To View
Iingmontoya9/20/2023

Merge two columns into one?

Hi, I'm new using filament and what I need is simple ( I believe ) I just want to display into one column (full name) two columns from model (firstName and lastName) tried with this but didn't work ... any ideas?
Solution:
what i do is create attribute inside my model
    public function getFullnameAttribute()
    {
        return $this->first_name.' '.$this->last_name;
    }
Message Not Public
Sign In & Join Server To View
Ggladjanus439/20/2023

Custom card Radio Button form field

Hi,

I have build a custom form field for displaying the radio button as a card with an image. Everything is working fine but I would like to add a border to the checked radio button.

I can't really figure out how to do it in the custom view. I know tailwind has some cool peer-checked options but I cannot get it working...

Does someone have a good idea how to solve this?
Thanks!
Solution:
For others:
In your blade file you need to add this to your input field. So the state gets updated every time the user changes the input. This directly sends a request to the server everytime if ->live() is added.
<input {{ $applyStateBindingModifiers('wire:model') }}="{{ $getStatePath() }}" />

Also make sure to make the component ->live() in your resource.

Then you can add classes dynamically by checking $getState() and apply classes to it.
@if ($getState() == $value) border-2 border-green-500 @endif
Rrimon_the_dev9/20/2023

Relation Manager + Repeater?

I am using a relation manager to display daily payroll entries. When editing such an entry, I would like to be able to display all of its associated 'service members' who were active on that day, via a BelongsToMany relationship. Unfortunately, it doesn't seem that the form is adding new entries on save, despite the database being updated. Am I doing this incorrectly?

SS1: First look
SS2: Adding a new SM
SS3: After saving

(Code in thread)
Tthejaww9/20/2023

How can i get a value from previous column?

TextColumn::make('fileable_type')
    ->sortable()
    ->searchable()
    ->label('Resource')
    ->formatStateUsing(function ($state) {
        $modelName = explode('\\', $state);
        return $modelName[count($modelName) - 1];
    }),
TextColumn::make('fileable_id')
    ->sortable()
    ->searchable()
    ->formatStateUsing(function ($state) {
        // how can i get `fileable_type` here
    })


i want to retrive fileable_type in second column.
Wwaleedgrt9/20/2023

infolist not woking?

I am using infolist on a custom page but the model is not loading.

Page
```
class AccountStatements extends Page implements HasForms, HasTable, HasInfolists
{
use InteractsWithForms;
use InteractsWithTable;
use InteractsWithInfolists;

protected static ?string $navigationIcon = 'heroicon-o-cog-8-tooth';

protected static ?string $navigationGroup = 'Reports';

protected static string $view = 'filament.pages.reports.accountStatement';

protected $listeners = [...