LeviBeezy
LeviBeezy
FFilament
Created by LeviBeezy on 5/14/2024 in #❓┊help
getTabs v3.2.77 error: trim(): Argument #1 ($string) must be of type string, Filament\Support\Enums\
Something has changed between Filament v3.2.76 and v3.2.77 with getTabs. In .76, this code works fine:
<?php

namespace App\Filament\Resources\EndpointResource\Pages;

use App\Filament\Resources\EndpointResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
use Filament\Resources\Components\Tab;
use Filament\Support\Enums\IconPosition;
use Illuminate\Database\Eloquent\Builder;
use Archilex\AdvancedTables\AdvancedTables;

class ListEndpoints extends ListRecords
{
protected static string $resource = EndpointResource::class;

use AdvancedTables;

public function getTabs(): array
{
return [
'all' => Tab::make('All')
->label('All')
->icon('heroicon-m-ellipsis-horizontal-circle')
->iconPosition(IconPosition::After),
'live' => Tab::make('Live')
->label('Live')
->icon('heroicon-o-signal')
->iconPosition(IconPosition::After)
->modifyQueryUsing(fn (Builder $query) => $query->where('status', 'Live')),
'pending' => Tab::make('Pending')
->label('Pending')
->icon('heroicon-o-bolt-slash')
->iconPosition(IconPosition::After)
->modifyQueryUsing(fn (Builder $query) => $query->where('status', 'Pending')),
'inactive' => Tab::make('Inactive')
->label('Inactive')
->icon('heroicon-m-signal-slash')
->iconPosition(IconPosition::After)
->modifyQueryUsing(fn (Builder $query) => $query->where('status', 'Inactive')),
];
}

}
<?php

namespace App\Filament\Resources\EndpointResource\Pages;

use App\Filament\Resources\EndpointResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
use Filament\Resources\Components\Tab;
use Filament\Support\Enums\IconPosition;
use Illuminate\Database\Eloquent\Builder;
use Archilex\AdvancedTables\AdvancedTables;

class ListEndpoints extends ListRecords
{
protected static string $resource = EndpointResource::class;

use AdvancedTables;

public function getTabs(): array
{
return [
'all' => Tab::make('All')
->label('All')
->icon('heroicon-m-ellipsis-horizontal-circle')
->iconPosition(IconPosition::After),
'live' => Tab::make('Live')
->label('Live')
->icon('heroicon-o-signal')
->iconPosition(IconPosition::After)
->modifyQueryUsing(fn (Builder $query) => $query->where('status', 'Live')),
'pending' => Tab::make('Pending')
->label('Pending')
->icon('heroicon-o-bolt-slash')
->iconPosition(IconPosition::After)
->modifyQueryUsing(fn (Builder $query) => $query->where('status', 'Pending')),
'inactive' => Tab::make('Inactive')
->label('Inactive')
->icon('heroicon-m-signal-slash')
->iconPosition(IconPosition::After)
->modifyQueryUsing(fn (Builder $query) => $query->where('status', 'Inactive')),
];
}

}
That same code results in this error in 3.2.77:
TypeError
PHP 8.3.6
10.48.10
trim(): Argument #1 ($string) must be of type string, Filament\Support\Enums\IconPosition given
TypeError
PHP 8.3.6
10.48.10
trim(): Argument #1 ($string) must be of type string, Filament\Support\Enums\IconPosition given
I'm not sure what I'm doing wrong, as that appears to be valid usage according to documentation.
14 replies
FFilament
Created by LeviBeezy on 3/21/2024 in #❓┊help
Can we adjust positioning of getOptionsFormComponents?
No description
5 replies
FFilament
Created by LeviBeezy on 3/20/2024 in #❓┊help
Dynamic Filename Specification for Export Actions
Currently, I leverage the getOptionsFormComponents() method to allow users to customize their export options, such as limiting column content. However, I noticed that while we can access these options in closure functions (like formatStateUsing), there's no direct, built-in method to apply these options to modify the exported file's name dynamically based on user input. What I'm Looking to Achieve: I wish to present a text input to users where they can specify a custom filename for their export file before initiating the export process. The goal is to directly use this user-specified filename for the export without resorting to workarounds such as session storage or predefined naming conventions. Suggestion: Would it be possible to introduce functionality or a method within the exporter class where $options could directly influence the getFileName method? For example, allowing getFileName to access $options provided through getOptionsFormComponents() would be incredibly beneficial. Example Use Case:
public static function getOptionsFormComponents(): array {
return [
TextInput::make('fileName')
->label('Custom Filename'),
];
}

// Ideally accessing options in getFileName or a similar approach
public function getFileName($export, $options): string {
return $options['fileName'] ?? 'default_name' . '.xlsx';
}
public static function getOptionsFormComponents(): array {
return [
TextInput::make('fileName')
->label('Custom Filename'),
];
}

// Ideally accessing options in getFileName or a similar approach
public function getFileName($export, $options): string {
return $options['fileName'] ?? 'default_name' . '.xlsx';
}
I also could be overlooking a way to do this with current functionality.
5 replies