urbycoz
urbycoz
FFilament
Created by urbycoz on 9/3/2024 in #❓┊help
How can I set default text in a RichEditor?
I want the content to display some custom text instead just being blank. Things like textInputs support ->default() but that doesn't seem to work for RichEditors. RichEditor::make('summary') ->default('my default text')
10 replies
FFilament
Created by urbycoz on 7/4/2024 in #❓┊help
Make a link that selects an option in a Select component
I've got a Form with a Select component with lots of options. I want to create a link saying "Custom item" which forces the option "Other" to be selected. Is that possible?
3 replies
FFilament
Created by urbycoz on 7/4/2024 in #❓┊help
Footer on Select component
No description
4 replies
FFilament
Created by urbycoz on 6/19/2024 in #❓┊help
Adding a "show more/less" toggle to long description in infolist
I have an infolist with a description TextEntry component that renders HTML. However some of the descriptions are quite long, so I would like to include a toggle button saying "show more" or "show less" to expand and shrink the content.

public function infolist(Infolist $infolist): Infolist
{
return $infolist
->record($this->product)
->schema(
TextEntry::make('description')
->html(),
);
}

public function infolist(Infolist $infolist): Infolist
{
return $infolist
->record($this->product)
->schema(
TextEntry::make('description')
->html(),
);
}
7 replies
FFilament
Created by urbycoz on 6/6/2024 in #❓┊help
How can I make my form action show a confirmation modal?
I have a form with a delete action. I want it to fire the doDelete() method when clicked. But I want a confirmation modal to show first. However the code below doesn't seem to work. When I click the button nothing shows. If I take out the ->requiresConfirmation() then the doDelete() method is fired fine.
public function form(Form $form): Form
{
return $form
->schema([
...
Actions::make([
Action::make('delete')
->requiresConfirmation() // This doesn't make a modal show
->action(function () {
$this->doDelete($this->item->id);
})
]),
]);
}
public function form(Form $form): Form
{
return $form
->schema([
...
Actions::make([
Action::make('delete')
->requiresConfirmation() // This doesn't make a modal show
->action(function () {
$this->doDelete($this->item->id);
})
]),
]);
}
5 replies
FFilament
Created by urbycoz on 5/15/2024 in #❓┊help
Hide modal heading without hiding cross
My table has a button called "Profile" which opens a modal. I want the modal to have all my own custom content (from components.person-profile) so I'm hiding the boilerplate heading. But this seems to also hide the cross close button in the top right of the modal. Is there a way to do this so the cross remains? Action::make('Profile') ->modalHeading('') // removes close button ->modalContent(fn (Person $record): View => view( 'components.person-profile', [ 'person' => $record, ], )),
6 replies
FFilament
Created by urbycoz on 5/6/2024 in #❓┊help
How can I prevent my FileUpload placeholder resetting
Here's my form with a fileupload component
public function fileUploadForm(Form $form): Form
{
return $form
->schema([
FileUpload::make('document')
->label('')
->maxSize($this->maxFileSize * 1024)
->multiple()
->disk('public')
->placeholder('this is my new placeholder')
->previewable(false),
]);
}
public function fileUploadForm(Form $form): Form
{
return $form
->schema([
FileUpload::make('document')
->label('')
->maxSize($this->maxFileSize * 1024)
->multiple()
->disk('public')
->placeholder('this is my new placeholder')
->previewable(false),
]);
}
And here's my method that gets called whenever a file is uploaded:
public function updatedDocument(): void
{
$document = Arr::last($this->document);
$documentPath = $this->storeDocument($document);

$data = [
'name'=>$document->title,
'path' => $documentPath,
];
$this->application->supportingDocuments()->create($data);
}
public function updatedDocument(): void
{
$document = Arr::last($this->document);
$documentPath = $this->storeDocument($document);

$data = [
'name'=>$document->title,
'path' => $documentPath,
];
$this->application->supportingDocuments()->create($data);
}
But for some reason the placeholder reverts to the default "Drag and drop your files or browse" message whenever a file gets uploaded. How can I stop this?
2 replies
FFilament
Created by urbycoz on 4/17/2024 in #❓┊help
uploadingMessage method does not work for FileUpload
I have a form with a fileUpload component and I'm trying to change the uploading text. use Filament\Forms\Components\FileUpload; FileUpload::make('attachment') ->uploadingMessage('Uploading attachment...') I'm trying to follow the documentation here: https://filamentphp.com/docs/3.x/forms/fields/file-upload But it seems the uploadingMessage doesn't actually exist because I get this error: Method Filament\Forms\Components\FileUpload::uploadingMessage does not exist.
4 replies
FFilament
Created by urbycoz on 4/16/2024 in #❓┊help
Using limit with default in datatable textcolumn
I've got a textcolumn with a default HTML column: TextColumn::make('title') ->label('Title') ->sortable() ->searchable() ->default(new HtmlString('<span class="bg-orange-100 text-orange-800 text-sm font-medium me-2 px-2.5 py-1.5 rounded inline-flex"> Missing Information </span>')) I also want to add a 30 character limit, but it seems to prevent the default working.
5 replies
FFilament
Created by urbycoz on 4/16/2024 in #❓┊help
Datatable pagination is showing "compact" version
I'm sure this is really obvious but I can't see what I'm doing wrong here. I've made a datatable and it's populating fine. But the pagination is not showing the page numbers and the "Showing x of y records" message. Instead it's showing "next" and "previous" buttons to navigate between pages. public function table(Table $table): Table { return $table ->query($this->getTableQuery()) ->columns($this->getTableColumns()) ->actions($this->getTableActions()) ->emptyStateHeading('No posts found'); }
4 replies
FFilament
Created by urbycoz on 4/16/2024 in #❓┊help
How can I show styled text if a cell is empty?
My datatable has the following column:
TextColumn::make('description') ->label('Description') ->placeholder('empty'), Instead of simply the text "empty" I want to show this styled version: '<span class="px-3 py-1 bg-blue-100 text-blue-800 text-sm rounded-full">Empty</span>' Is this possible?
5 replies
FFilament
Created by urbycoz on 4/4/2024 in #❓┊help
Get current tab from outside of infolist
I've got a blade file containing an infolist that uses the tabs component. I want to be able to access the active tab name from outside of the infolist but I can't figure out a way to do this. PHP livewire component public function infolist(Infolist $infolist): Infolist { return $infolist ->schema($this->getInfolistSchema()); } private function getInfolistSchema() { return [ Tabs::make('Tabs') ->tabs([ Tab::make('Tab1') ->schema([ // tab 1 schema ]), Tab::make('Tab2') ->schema([ // tab 2 schema ]), ]) ->persistTabInQueryString() ->id('my-tabs'), ]; } Parent Blade component <div class="parentContainer"> Current tab is <!-- insert tab name here --> <livewire:my-tabber/> </div> Child Blade component <div class="childContainer"> {{ $this->infolist }} </div>
2 replies
FFilament
Created by urbycoz on 3/26/2024 in #❓┊help
Can I defer uploading via the FileUpload component until form submission
I'm using Filament's file upload component in my form within my livewire component: https://filamentphp.com/docs/3.x/forms/fields/file-upload Currently the way it works is that the user selects or drops their file onto the uploader and it immediately uploads. What I'd really like is for the upload itself to be deferred until the user has filled in the rest of the form. Is this possible?
3 replies
FFilament
Created by urbycoz on 3/25/2024 in #❓┊help
How can I add a debounce to my autosaving form field?
I have set up a filament form using Livewire. It has one textinput which autosaves when the user types anything. However I'd really like to add a debounce, so it only saves when the user has stopped typing to 0.5 seconds. Is this possible? PHP Livewire component class class UsernameEntry extends Livewire\Component implements HasForms { use InteractsWithForms; ... public function form(Form $form): form { return $form->schema([ TextInput::make('username') ->live(), ])->statePath('data'); $this->dispatch('showSaveMessage'); } public function updatedData($value): void { $this->application->username = $value; $this->application->save(); } } Blade Livewire component <form wire:submit="save"> {{ $this->form }} </form>
5 replies
FFilament
Created by urbycoz on 3/17/2024 in #❓┊help
Can I change the default FileUpload Text?
In the Filament Form FileUpload component, is it possible to change the default text from "Drag & Drop you files or browse" to say something else?
6 replies
FFilament
Created by urbycoz on 1/18/2024 in #❓┊help
Searching in a table on a column using a polymorphic relationship
I have an Account model that has a Contact relation. The Contact relation can represent different entities: Customer or Employee.
//Account Model
public function contact(): MorphTo
{
return $this->morphTo(__FUNCTION__, 'contactidtype', 'contactid');
}
//Account Model
public function contact(): MorphTo
{
return $this->morphTo(__FUNCTION__, 'contactidtype', 'contactid');
}
//Customer & Employee Models
public function account(): MorphOne
{
return $this->morphOne(Account::class, 'contact', 'contactidtype', 'contactid');
}
//Customer & Employee Models
public function account(): MorphOne
{
return $this->morphOne(Account::class, 'contact', 'contactidtype', 'contactid');
}
Customers has a field named cust_name. Employees has a field named emp_name. I'm trying to implement a search functionality on the Account model that allows searching for accounts based on the name, which is created in a combinedName aggregated attribute. Is there a way to solve this without changing the database tables themselves? The below code doesn't work because there's not an emp_name column in the Customers table no and no cust_name field in the Employees table.
TextColumn::make('combinedName')
->searchable(query: function (Builder $query, string $search): Builder {
return $query->where(function ($query) use ($search) {
$query->where('contact_type', 'Customer')
->whereHas('contact', function (Builder $q) use ($search) {
$q->where('cust_name', 'ILIKE', "%{$search}%");
});
})
->orWhere(function ($query) use ($search) {
$query->where('contact_type', 'Employee')
->whereHas('contact', function (Builder $q) use ($search) {
$q->where('emp_name', 'ILIKE', "%{$search}%");
});
})
}, isIndividual: true)
TextColumn::make('combinedName')
->searchable(query: function (Builder $query, string $search): Builder {
return $query->where(function ($query) use ($search) {
$query->where('contact_type', 'Customer')
->whereHas('contact', function (Builder $q) use ($search) {
$q->where('cust_name', 'ILIKE', "%{$search}%");
});
})
->orWhere(function ($query) use ($search) {
$query->where('contact_type', 'Employee')
->whereHas('contact', function (Builder $q) use ($search) {
$q->where('emp_name', 'ILIKE', "%{$search}%");
});
})
}, isIndividual: true)
6 replies
FFilament
Created by urbycoz on 1/16/2024 in #❓┊help
How can I get data into infolist without using aggregated attributes?
I've got an infolist with lots of TextEntry fields, many of which do not correspond directly to a database column, but instead use aggregated attributes on the Customer model. //Component TextEntry::make('Customer.customerDetails')->label('Customer Details') //Attribute in Customer model public function getCustomerDetailsAttribute(): string { //business logic to build customer details return $customerDetails; } However, this has led to my Customer model becoming very large and unwieldy. Is there a way to do this without the aggregated attributes, perhaps by passing a closure into the TextEntry component directly?
2 replies
FFilament
Created by urbycoz on 1/10/2024 in #❓┊help
How can I dynamically update my Select options based on an API
I've got a textInput where a user can enter their zipcode/postcode and a button that does a lookup via an API. I'd like to find a way to make the options in the Select update. Is it possible?
private $addresses;
...

TextInput::make('addressLookupText')
->label('Address Lookup'),
Actions::make([
Action::make('Address Lookup Button')
->label('Find Address')
->action(function (Get $get) {
$this->addresses = $this->findAddresses($get('addressLookupText'));
}),
]),
Select::make('addresses')
->options($this->addresses)
->label('Select an address'),
private $addresses;
...

TextInput::make('addressLookupText')
->label('Address Lookup'),
Actions::make([
Action::make('Address Lookup Button')
->label('Find Address')
->action(function (Get $get) {
$this->addresses = $this->findAddresses($get('addressLookupText'));
}),
]),
Select::make('addresses')
->options($this->addresses)
->label('Select an address'),
6 replies
FFilament
Created by urbycoz on 12/15/2023 in #❓┊help
Set properties for current table only
I have a table with lots of columns. Rather than set each one of them to sortable individually I am using the following: public function boot() { TextColumn::configureUsing(function (TextColumn $textColumn): void { $textColumn->sortable(); }); } However this isn't ideal since it sets the property globally and might affect other tables elsewhere in the system. Is there a way to limit the scope only to one particular table?
4 replies
FFilament
Created by urbycoz on 12/11/2023 in #❓┊help
How can I stop my Select options getting reset when visibility toggled
I've got a form with a toggle and a select. When the toggle is turned off the select should be hidden. But when I toggle back on the select has its options removed. How can I stop this happening? Section::make('Contact Address') ->schema([ Toggle::make('useSameAddress') ->label('Same as residential address')
->live() ->reactive(), Grid::make(1) ... ->schema([
Select::make('contactcountry') ->extraAttributes(['class' => 'contact_country']) ->placeholder('Select option') ->searchable() ->options($this->countries) ->label('Country'), ]) ->hidden( fn (Get $get): bool => $get('useSameAddress') === true ) ]),
2 replies