urbycoz
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
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.
7 replies
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.
5 replies
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
How can I prevent my FileUpload placeholder resetting
Here's my form with a fileupload component
And here's my method that gets called whenever a file is uploaded:
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
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
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
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
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
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
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
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
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
.
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.
6 replies
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
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?
6 replies
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
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 ) ]),
->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