rominronin
rominronin
FFilament
Created by rominronin on 6/18/2024 in #❓┊help
Action icon color
No description
2 replies
FFilament
Created by rominronin on 1/15/2024 in #❓┊help
How mature do you see the filament project?
Background: We are currently upgrading from v2 to v3, we welcome the new features, but it's proving to be more time consuming than we anticipated. This got us thinking about v3 to v4. I want to get a discussion going (rather than expecting an impossible answer) about the current maturity, the roadmap of the filament project. Partly to inform ourselves, but also because we want to be able to make better estimates for our clients - this particular upgrade will come at a loss for us, which is fine - we knew it was a young project going in.
2 replies
FFilament
Created by rominronin on 12/7/2023 in #❓┊help
Sorting a table component (not a resource) not working
Hello, I have a component which displays a table. The query is just the all() method on the relevant model. I have some custom filters with select fields, that all work to update the query and therefore the table results. I want the sort to be selectable, so I made a select field , with the option to sort a given column asc or desc. The records will not update however:
public function getTableQuery() {
return FeaturedProduct::query();
}

protected function getTableFilters(): array
{
return [
Tables\Filters\Filter::make('filter_sort')
->form([
Select::make('sort')
->label(__('configurator.teaser.sort'))
->reactive()
->default(3)
->helperText(__('featured.filter.sort.helptext'))
->options([
1 => __('featured.sort.price_asc'),
2 => __('featured.sort.price_desc'),
3 => __('featured.sort.default')
]),
])
->query(function (Builder $query, $data, $livewire) {
$sort = $data['sort'] ?? NULL;
switch ($sort) {
case 1:
return $query->orderBy('price_total');
break;
case 2:
return $query->orderByDesc('price_total');
break;
case 3:
return $query->orderByDesc('weight');
break;
}
return $query;
}),
];
}
public function getTableQuery() {
return FeaturedProduct::query();
}

protected function getTableFilters(): array
{
return [
Tables\Filters\Filter::make('filter_sort')
->form([
Select::make('sort')
->label(__('configurator.teaser.sort'))
->reactive()
->default(3)
->helperText(__('featured.filter.sort.helptext'))
->options([
1 => __('featured.sort.price_asc'),
2 => __('featured.sort.price_desc'),
3 => __('featured.sort.default')
]),
])
->query(function (Builder $query, $data, $livewire) {
$sort = $data['sort'] ?? NULL;
switch ($sort) {
case 1:
return $query->orderBy('price_total');
break;
case 2:
return $query->orderByDesc('price_total');
break;
case 3:
return $query->orderByDesc('weight');
break;
}
return $query;
}),
];
}
This filter works the same way as the other, working filters, but it seems that ordering is restricted, because all the 'where's work, just the 'order's do not. What am I missing here? Thanks
2 replies
FFilament
Created by rominronin on 11/8/2023 in #❓┊help
Fileupload resize doesn't seem to work, what am I missing?
The field on the resource is configured as follows:
Forms\Components\FileUpload::make('image')
->image()
->imageResizeMode('contain')
->imageCropAspectRatio('4:3')
->imageResizeTargetWidth(400)
->imageResizeTargetWidth(300)
Forms\Components\FileUpload::make('image')
->image()
->imageResizeMode('contain')
->imageCropAspectRatio('4:3')
->imageResizeTargetWidth(400)
->imageResizeTargetWidth(300)
With the above settings, cropping definitely works, as the preview saved image has the define dimensions and aspect ratio. But if the uploaded file has an aspect ratio that is not 4:3, then the image is simply cropped before resize. eg. before and after images here: https://imgur.com/a/KeztyX0
8 replies
FFilament
Created by rominronin on 6/28/2023 in #❓┊help
Search translation text (not just key)
The filament translation library is great, we are using it extensively on a project. There is one big UX issue that I would love to be able to solve. The search function doesn't search the translated text values, which kind of diminishes its usefulness, since often our users are not aware what the key is (and even with better key labelling, the should be able to query the translated text). Are there any known solutions to this? Thanks.
2 replies
FFilament
Created by rominronin on 6/27/2023 in #❓┊help
Custom field layout component does not pass $extraAttributes to blade
Hi, I followed the instructions here to create a custom layout component: https://filamentphp.com/docs/2.x/forms/layout#building-custom-layout-components in the generated blade there is an $extraAttributes variable, but I cannot pass it via the form builder as you would expect - what is missing here? Thanks ```php CustomComponent::make() ->extraAttributes(['class' => 'not-passed-to-blade']) ->schema([])
2 replies
FFilament
Created by rominronin on 6/24/2023 in #❓┊help
Refactoring closures into a trait (or some other structure)
I have a very large form with tonnes of dependant fields, dynamic hints, options etc. The entire form is full of closures and it's getting to a state where it's unweildy. I was wondering if it's possible to refactor the code into a trait or some other file where I can keep the various functions organised. eg. I have the following
->afterStateHydrated(fn(callable $get, callable $set) => $this->hydrateProduct($get, $set))
->afterStateHydrated(fn(callable $get, callable $set) => $this->hydrateProduct($get, $set))
With a public function doing the legwork:
public function hydrateProduct($get = null, $set = null)
{
if ($get('product')) {
$this->product = Product::find($get('product'));
if ($this->product) {
$set('dependant_field', null);
$set('manufacturer', $this->product->manufacturer->id);
$set('price', $this->product->price);
}
}
}
public function hydrateProduct($get = null, $set = null)
{
if ($get('product')) {
$this->product = Product::find($get('product'));
if ($this->product) {
$set('dependant_field', null);
$set('manufacturer', $this->product->manufacturer->id);
$set('price', $this->product->price);
}
}
}
When I move hydrateProduct into a trait though, I get errors, eg: Argument #1 ($get) must be of type callable, null given, called in /private/var/www/vhosts/gunthertore/vendor/livewire/livewire/src/HydrationMiddleware/CallPropertyHydrationHooks.php on line 20 make $get null by default: App\Http\Livewire\Configurator\SectionalDoors::hydrateProduct(): Argument #2 ($set) must be of type callable, Livewire\Request given, called in /private/var/www/vhosts/gunthertore/vendor/livewire/livewire/src/HydrationMiddleware/CallPropertyHydrationHooks.php on line 20 Liverwire\Request? OK: App\Http\Livewire\Configurator\SectionalDoors::hydrateProduct(): Argument #2 ($set) must be of type Livewire\Request, Closure given, called in /private/var/www/vhosts/gunthertore/app/Http/Livewire/Configurator/SectionalDoors.php on line 124 You get the picture. What am I doing wrong? Is this even possible? Is there a better way to separate the functions out than this? Thanks
2 replies
FFilament
Created by rominronin on 5/2/2023 in #❓┊help
I'm encountering a bug in form Repeater?
I have a repeater that creates a Select field, the options array for the repeater should be dynamically updated based on other form fields:
Select::make('panel_insert')
->options(function (callable $get) {
$panels = Panel::where('manufacturer_id',$get('manufacturer'))
->where('use', $get('use'))
->whereHas('panelType', function ($query){
$query->where('insertable', TRUE);
})
->get();
$options = [];
if ($panels) {
foreach ($panels as $panel) {
$options[$panel->id] = $panel->panelType->name.", ".$panel->panelSurface->name;
}
return $options;
}
})
Select::make('panel_insert')
->options(function (callable $get) {
$panels = Panel::where('manufacturer_id',$get('manufacturer'))
->where('use', $get('use'))
->whereHas('panelType', function ($query){
$query->where('insertable', TRUE);
})
->get();
$options = [];
if ($panels) {
foreach ($panels as $panel) {
$options[$panel->id] = $panel->panelType->name.", ".$panel->panelSurface->name;
}
return $options;
}
})
The issue is that $get('manufacturer') and $get('use') returns null in the closure, even though they are non-empty fields. The code works in other fields (this is a copy-paste of another, similar field). I tested the closure and it returns the expected select options when the correct ids are returned. My issue is that $get('field_value') is always empty in the Repeater closure. Any ideas? Thanks
6 replies