bernhard
bernhard
FFilament
Created by bernhard on 8/10/2024 in #❓┊help
Hint Action - Copy value
I wanna add a hint action to a Builder field, which should copy the $state into the browser clipboard. This is what I got so far:
->hintAction(Action::make('copyJson')
->label("Inhalt exportieren")
->icon('heroicon-m-clipboard')
->action(function (Get $get, $state) {
dd(json_encode($state, JSON_PRETTY_PRINT));
}),
),
->hintAction(Action::make('copyJson')
->label("Inhalt exportieren")
->icon('heroicon-m-clipboard')
->action(function (Get $get, $state) {
dd(json_encode($state, JSON_PRETTY_PRINT));
}),
),
This already show the button and on click it dd's the json of the Builder field state. But how to copy the value to clipboard, instead of dding? How can I call JS navigator.clipboard.writeText(copyText.value);? Just to understand, what I wanna achieve: Later I will change it to
->hintAction(fn() => [
Action::make('copyJson')
->label("Inhalt exportieren")
->icon('heroicon-m-clipboard')
->action(function (Get $get, $state) {
...
}),
Action::make('importJson')
->label("Inhalt importieren")
->icon('heroicon-m-arrow-down-on-square')
->form(fn($state) => [
TextArea::make('copyJsonTextarea')
])
->action(function (Get $get, $state) {
...
})
])
->hintAction(fn() => [
Action::make('copyJson')
->label("Inhalt exportieren")
->icon('heroicon-m-clipboard')
->action(function (Get $get, $state) {
...
}),
Action::make('importJson')
->label("Inhalt importieren")
->icon('heroicon-m-arrow-down-on-square')
->form(fn($state) => [
TextArea::make('copyJsonTextarea')
])
->action(function (Get $get, $state) {
...
})
])
so that I can import/export the Builder value.
4 replies
FFilament
Created by bernhard on 8/1/2024 in #❓┊help
Action outside of the panel not showing modals
I have a component outside of the panel:
class Search extends Component implements HasForms, HasActions
{
use InteractsWithActions;
use InteractsWithForms;


public function render(): View
{
return view('livewire.search');
}


public function deleteAction(): Action
{
return Action::make('delete')
->requiresConfirmation()
->action(fn () => dd(1));
}
}
class Search extends Component implements HasForms, HasActions
{
use InteractsWithActions;
use InteractsWithForms;


public function render(): View
{
return view('livewire.search');
}


public function deleteAction(): Action
{
return Action::make('delete')
->requiresConfirmation()
->action(fn () => dd(1));
}
}
<div>
{{ $this->deleteAction }}
</div>
<div>
{{ $this->deleteAction }}
</div>
When clicking on the button, nothing happens, no confirm modal is shown. In Dev-Toolbar I see no error. Only thing I can see is that the attribute disabled=true is set for a second. When I now remove the ->requiresConfirmation() and click again, I can see the dd output. Same goes for custom modals - the modal isn't show. Nothing happens:
Action::make('delete')
->form([
TextInput::make("search")
])
->action(fn () => dd(1));
Action::make('delete')
->form([
TextInput::make("search")
])
->action(fn () => dd(1));
9 replies
FFilament
Created by bernhard on 3/21/2024 in #❓┊help
Filament v2 - Color picker lazy/debounce
I am using filament v2 and I have a colorpicker field. Since I use the value of this field in another field, the field is reactive:
ColorPicker::make('color')->reactive()
ColorPicker::make('color')->reactive()
This works, but I just wanna get updates, after the color was picked and not on moving the circle of the colorpicker around. Neither lazy() nor debounce("5000ms") works? Is this a bug?
2 replies
FFilament
Created by bernhard on 3/6/2024 in #❓┊help
Weird login error after livewire update
After composer update I can't login to filament. I see the login form but the password field is a regular input field (i can see the password when typing) and when clicking on the login button, I get The POST method is not supported for route admin/login. Supported methods: GET, HEAD. I could track it down to the latest release (3.4.7) of livewire. When doing
composer require livewire/livewire:v3.4.6 -W
composer require livewire/livewire:v3.4.6 -W
It is working again. Has anyone seen this issue? Is this Filament or Livewire related?
4 replies
FFilament
Created by bernhard on 1/31/2024 in #❓┊help
FileUpload in process, how to disable button outside panel?
I have an v2 form outside the panel with an FileUpload. How to disable a submit button, while FileUpload is ongoing? wire:loading.attr="disabled" is only working for the save process itself, but not for the uploading in background. This is what I have tried atm:
<button wire:click='submit' wire:loading.attr="disabled">
Save
</button>
<button wire:click='submit' wire:loading.attr="disabled">
Save
</button>
1 replies
FFilament
Created by bernhard on 1/22/2024 in #❓┊help
"Create another" and prefill field
When creating a new record in the panel and clicking on the "create & create another" button, is there a way to reuse some of the values of the current fields for the new "new form"? For example, I have the following fields - name (string) - category_id (Select with relationship) - country_id (Select with relationship) When a user now types/selects: - name: XYZ - category_id: 1 - country_id: 4711 and clicks on the "create & create another" button, the entry is saved and he is redirected to a new and empty "Create" form. I want that the new "Create" form is now prefilled with - category_id: 1 - country_id: 4711 Possible?
5 replies
FFilament
Created by bernhard on 1/16/2024 in #❓┊help
Problem with remember per page setting
No description
2 replies
FFilament
Created by bernhard on 1/10/2024 in #❓┊help
Can't use svg in TextColumn
What I want to achive is a column which shows an icon and when you click on it, a defined text is copied to the clipboard. The problem is, that the IconColumn has no copyable method, so I tried to use the TextColumn:
TextColumn::make("copy_column")
->getStateUsing("Copy")
->copyable()
->copyableState(fn($record) => $record->id)
TextColumn::make("copy_column")
->getStateUsing("Copy")
->copyable()
->copyableState(fn($record) => $record->id)
this works as expected and it shows the text "Copy". Now I tried to use an icon:
TextColumn::make("copy_column")
->getStateUsing(function() {
return new HtmlString(
'<svg style="width: 20px; height: 20px;" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true">
<path stroke-linecap="round" stroke-linejoin="round" d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"></path>
</svg>');
})
->html()
->copyable()
->copyableState(fn($record) => $record->id)
TextColumn::make("copy_column")
->getStateUsing(function() {
return new HtmlString(
'<svg style="width: 20px; height: 20px;" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true">
<path stroke-linecap="round" stroke-linejoin="round" d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"></path>
</svg>');
})
->html()
->copyable()
->copyableState(fn($record) => $record->id)
but the column is empty. Any ideas?
31 replies
FFilament
Created by bernhard on 12/12/2023 in #❓┊help
Property type not supported in Livewire when using computedProperties
I tried to create a resource for some third party model (Spatie\UptimeMonitor\Models\Monitor). This model uses the following method:
public function getUrlAttribute(): ?Url
{
if (! isset($this->attributes['url'])) {
return null;
}

return Url::fromString($this->attributes['url']);
}
public function getUrlAttribute(): ?Url
{
if (! isset($this->attributes['url'])) {
return null;
}

return Url::fromString($this->attributes['url']);
}
On edit page, I get now an exception Property type not supported in Livewire for property: [{}] The weird thing is, that i get this exception, even if I dont use the url property at all in the form:
public static function form(Form $form): Form
{
return $form
->schema([]);
}
public static function form(Form $form): Form
{
return $form
->schema([]);
}
When commenting the getUrlAttribute out from the package, the error isn't thrown. Any ideas how to get around this error, without messing up the package?
6 replies
FFilament
Created by bernhard on 11/20/2023 in #❓┊help
Widget with filter - mobile
No description
6 replies
FFilament
Created by bernhard on 11/17/2023 in #❓┊help
Allow comma sign in TagsInput
Is there a way, to allow a comma sign in an TagsInput value? As soon as I enter a comma sign "," in the TagsInput, the tag is added. But I just wanna add for example names as tags in the format - "John, Doe" - "Foo, Bar" - "Jean-Claude, Van-Cool" So is there a way, do disable tag recognition with ",", and just use Enter (or change it to semicolon)
3 replies
FFilament
Created by bernhard on 11/4/2023 in #❓┊help
Issues beeing automatically closed for no reason
I have created this issue https://github.com/filamentphp/filament/issues/9459 on github, but the bot closed it 1 minute after. I have provided all necessary informations, I created a repo to reproduce. What did I wrong?
6 replies
FFilament
Created by bernhard on 10/22/2023 in #❓┊help
Disable buttons and fields, while loading
What is the best/prefered way of disableing the form fields and buttons, while a submit request is done? I am talking about v2 and (standalone) form, not admin-panel
2 replies
FFilament
Created by bernhard on 10/16/2023 in #❓┊help
Multiple tables on the same page
Is there a way to have multiple tables on the same page (not inside a panel)? I have a fullpage livewire component, where I display 2 tables and a button. Something like this:
<div>
<button type="submit" wire:click.prevent="submit" class="float-right btn">Button</button>

@livewire("table1")
@livewire("table2")
</div>
<div>
<button type="submit" wire:click.prevent="submit" class="float-right btn">Button</button>

@livewire("table1")
@livewire("table2")
</div>
Where the submit method does nothing atm (but gets called - tested it with dd):
public function submit(): void
{
//dd(1);
}
public function submit(): void
{
//dd(1);
}
This works - both tables are rendered correctly. But when I click the "Button" button, I get the following error in the JS console:
index.js:34 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'fingerprint')
index.js:34 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'fingerprint')
The index.js is just the combined js from livewire, where the error code looks like:
...
constructor(el, connection) {
el.__livewire = this
this.el = el
this.lastFreshHtml = this.el.outerHTML
this.id = this.el.getAttribute('wire:id')
this.checkForMultipleRootElements()
this.connection = connection
const initialData = JSON.parse(this.el.getAttribute('wire:initial-data'))
this.el.removeAttribute('wire:initial-data')
this.fingerprint = initialData.fingerprint // <- Error line
...
constructor(el, connection) {
el.__livewire = this
this.el = el
this.lastFreshHtml = this.el.outerHTML
this.id = this.el.getAttribute('wire:id')
this.checkForMultipleRootElements()
this.connection = connection
const initialData = JSON.parse(this.el.getAttribute('wire:initial-data'))
this.el.removeAttribute('wire:initial-data')
this.fingerprint = initialData.fingerprint // <- Error line
Furthermore, the two tables also swap positions (table2 is now the first table, table1 the second). When removing one of the table (doesn't matter which one), the error doesn't occure. Any ideas? PS: All the table functionalities, like paging, are working.
3 replies
FFilament
Created by bernhard on 10/4/2023 in #❓┊help
Chart tooltip color is wrong
No description
8 replies
FFilament
Created by bernhard on 10/2/2023 in #❓┊help
Using dates for filtering charts (widget)
Is there a build in way, to use dates (datepicker) for filtering chart widget? I know, I can create a selectbox with something like "last 7 days", "last 30 days" ,etc. but how to filter exact dates and show a filter which is not a selectbox?
7 replies
FFilament
Created by bernhard on 9/22/2023 in #❓┊help
Action run code and open url in new tab
Is there a way, to open a new tab in the action method of an (Table-)Action? Something like this:
Action::make("action")
->action(function ($record, Action $action) {
// run some code and then open a new tab with the url generated from the code
})
Action::make("action")
->action(function ($record, Action $action) {
// run some code and then open a new tab with the url generated from the code
})
I know, there is the method url, but I wanna run the code only, when the user clicks on the button. The action will generate a token (and save it to db) and the token will be attached to the url. Since I wanna have a new tab, redirect isn't an option. Is there a way, to just call JS on an action?
3 replies
FFilament
Created by bernhard on 9/21/2023 in #❓┊help
Two panels with two auth guards, logges me out from both
I have two panels: admin and partner. First is using the web guard, second the partner guard (see config/auth.php):
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'partner' => [
'driver' => 'session',
'provider' => 'users',
],
],
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'partner' => [
'driver' => 'session',
'provider' => 'users',
],
],
$panel->path("admin")->authGuard("web")
...
$panel->path("partner")->authGuard("partner")
$panel->path("admin")->authGuard("web")
...
$panel->path("partner")->authGuard("partner")
It works. When navigating to /admin I can login as admin, and when going to /partner I can login as a partner. Now I am logged in as 2 different users as expected. But when I click on logout on one of the panel, I am logged out in the other panels as well. That makes no sense? When putting on of the panels on a (sub-)domain, then it works as well, but when I log out from one, I stay logged in in the other panel (this is the expected behaviour IMHO).
12 replies
FFilament
Created by bernhard on 9/21/2023 in #❓┊help
Table column searchable - how to show user which columns are searchable
In the table builder, you can make columns searchable, which is great. For example:
TextColumn::make('id'),
TextColumn::make('name')->searchable(),
TextColumn::make('title')->searchable(),
TextColumn::make('description')
TextColumn::make('id'),
TextColumn::make('name')->searchable(),
TextColumn::make('title')->searchable(),
TextColumn::make('description')
So the name and title columns are searchable, but not the id and description column. From an end user perspective: how to know, which fields/columns are searchable and which not? When I enter for example 12, without any extra knowledge / information, I would expect to get the row with the id 12 or at least with 12 in it. Why not adding the names (labels) of the columns as a placeholder in the searchbox. Or mark the searchable columns somehow ?
5 replies
FFilament
Created by bernhard on 9/5/2023 in #❓┊help
Showing Widget in Modal
I have created a (chart) widget for a resource to show the stats of a (single) resource in a line chart. Is there a way to show this widget in a modal, when clicking on an Table (List records) Action? Somehing like:
Tables\Actions\Action::make("stats")
->widgets([
MyWidget::class
]);
Tables\Actions\Action::make("stats")
->widgets([
MyWidget::class
]);
4 replies