bionary
bionary
FFilament
Created by bionary on 9/30/2024 in #❓┊help
Date + Time Steppers / Meridiem
I'm cannot find a happy solution between using the native HTML5 datetime vs Filament's datetime implementation. - I'm in U.S. and 12 hour clock (with meridien) doesn't seem to be possible with ->native(false) - But when using the native HTML5 datetime steppers don't work: ->minutesStep(5) Anybody else facing these annoyances and find solutions? Is there a way to get both 5-minute steps AND a 12-hour clock?
2 replies
FFilament
Created by bionary on 8/21/2024 in #❓┊help
Show First image: SpatieMediaLibraryImageColumn
How can I limit the "thumb" image in my table to the first image only when my record has more than one Spatie Media records associated? I am using SpatieMediaLibraryImageColumn and always have several media images related...but they are cluttering up the table. I want to show the first one only. I thought I could directly fetch what I need (pseudo-code): ->getStateUsing(fn($record) => $record->getFirstMedia()...) But, it appears that ->getStateUsing() is ignored completely
15 replies
FFilament
Created by bionary on 7/15/2024 in #❓┊help
Spatie Media Library Conversion Quality NOT Applied
When I convert a PNG using the model method ->addMediaConversion() the ->quality() setting is ignored when combined with ->background('#ffffff') This is problem for all PNGs with transparent backgrounds. You have to explicitly set the background or else it ends up black in the coverted jpegs. I ran into this problem about 6 months ago...I ignored it. I just upgraded related composer packages and tried again. Still getting these results. Can anybody offer and help? (Note: "works for me" comments are not necessary and counter-productive) Thanks!
11 replies
FFilament
Created by bionary on 7/13/2024 in #❓┊help
Spatie Media Library breaks with ->disabled()
There appears to be a bug when using Spatie Media Library with the ->disabled() method. Saving the record throws an error, because it is trying to save the media to a column on the model (rather than in the media table)
SpatieMediaLibraryFileUpload::make("my_download")
->disk('media')
->disabled(fn() :bool => false),
SpatieMediaLibraryFileUpload::make("my_download")
->disk('media')
->disabled(fn() :bool => false),
This yields error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'my_download' in 'field list' Once ->disabled() is removed the plugin works as intended. plugin v. 3.2.93
9 replies
FFilament
Created by bionary on 6/26/2024 in #❓┊help
Anybody find a decent solution for table images to a lightbox?
(I'm surprised filament doesn't have a builtin lightbox for table records...it seems to have everything else imaginable!) The 2 lightbox plugins are not solutions. - https://filamentphp.com/plugins/njxqlus-lightbox This plugin doesn't support use in tables, so that's of no help here. - https://filamentphp.com/plugins/solution-forest-simplelightbox This plugin simply doesn't work and doesn't seem to be actively maintained.
10 replies
FFilament
Created by bionary on 3/10/2024 in #❓┊help
Fire js event from SelectColumn
I cannot seem to fire an event from SelectColumn in v2. of filament.
Tables\Columns\SelectColumn::make('status')
->action(function ($record, $livewire) {
dd('nothing works here');
})
Tables\Columns\SelectColumn::make('status')
->action(function ($record, $livewire) {
dd('nothing works here');
})
Even when inspecting the console there doesn't seem to be any events triggered at all with the select column change. effects.dirty[] How can I trigger a js event when I change the dropdown here?
10 replies
FFilament
Created by bionary on 2/28/2024 in #❓┊help
How to Refresh Form in RelationManager?
I have a relationManager and I need to refresh the form data after an action from the Footer Bar executes.
public function table(Table $table): Table
{
return $table
...
->actions([
Tables\Actions\EditAction::make()
->extraModalFooterActions([
\Filament\Tables\Actions\Action::make('do-this')
->label('Do This')
->action(function($record){
//1 Do something that updates $record
//2 Refresh form data

})
]),
Tables\Actions\DeleteAction::make(),
])
...
public function table(Table $table): Table
{
return $table
...
->actions([
Tables\Actions\EditAction::make()
->extraModalFooterActions([
\Filament\Tables\Actions\Action::make('do-this')
->label('Do This')
->action(function($record){
//1 Do something that updates $record
//2 Refresh form data

})
]),
Tables\Actions\DeleteAction::make(),
])
...
Any ideas how to refresh the form after clicking the action?
2 replies
FFilament
Created by bionary on 2/10/2024 in #❓┊help
Refreshing Form F v2
I have a scenario in which I alter saved model properties using model events: static::saving() ... As a result I need to refresh the form fields after being saved, because they are sometimes changed on the backend. Using filament v2 here...I cannot get this to work. On my edit page of resource:
protected $listeners = ['refreshFormData' => '$refresh'];

protected function afterSave(): void
{
$this->dispatchBrowserEvent('refreshFormData');
}
protected $listeners = ['refreshFormData' => '$refresh'];

protected function afterSave(): void
{
$this->dispatchBrowserEvent('refreshFormData');
}
This does't work. Have any ideas?
1 replies
FFilament
Created by bionary on 1/20/2024 in #❓┊help
Filters applied on load?
using Filament v.2 I have a table widget with some filters. I have a "less then pricing" filter for input pricing. When the page/table loads the filter is being applied automatically with a value == 0. How do I prevent table widget filters from being applied on load? (with filament v.2) Relevant code:
Filter::make('max_price')
->form([
TextInput::make('max_price_input')->label('Maximum price')
])->columns(2)
->query(fn (Builder $query, $data): Builder => $query
->where('price', '<=', (int)$data['max_price_input'])
)
->indicateUsing(function (array $data): array {
$indicators = [];
if ($data['max_price_input'] ?? null) {
$indicators['max_price_input'] = 'Max price = $' . number_format($data['max_price_input'], 0);
}
return $indicators;
})
Filter::make('max_price')
->form([
TextInput::make('max_price_input')->label('Maximum price')
])->columns(2)
->query(fn (Builder $query, $data): Builder => $query
->where('price', '<=', (int)$data['max_price_input'])
)
->indicateUsing(function (array $data): array {
$indicators = [];
if ($data['max_price_input'] ?? null) {
$indicators['max_price_input'] = 'Max price = $' . number_format($data['max_price_input'], 0);
}
return $indicators;
})
2 replies
FFilament
Created by bionary on 6/28/2023 in #❓┊help
ToggleColumn Alpine Error
Anybody try ToggleColumn lately? I haven't used a ToggleColumn on a table in a long time...used it today and it seems broken. I get a js console error: "module.esm.js:421 Alpine Expression Error: await is only valid in async functions and the top level bodies of modules" My front end skills are garbage and to the best of my knowledge I haven't done anything out of the ordinary to cause this. Any ideas?
4 replies
FFilament
Created by bionary on 6/28/2023 in #❓┊help
Persist data via relationship manager Create & Create Again
On a normal page form I can persist data for auto-filling in repetitive fields by flashing the session on save like:
public function createAnother(): void
{
session()->flash('dataFill', $this->data);
parent::createAnother();
}
public function createAnother(): void
{
session()->flash('dataFill', $this->data);
parent::createAnother();
}
Now I need to do this with the Relationship Manager. When attaching records how can I access the save and save another action to flash the session?
1 replies
FFilament
Created by bionary on 6/27/2023 in #❓┊help
Multi-Select Relationship by Image / Visually
I have a model: Exhibition which can have many Models: Artwork
How can I give the same same experience/results as a mulit-select \Forms\Components\Select() BUT with images rather than a text dropdown. In short I need the user to be able to search for images and select them to assign many artwork images to a single exhibition. Should I but using select? or maybe a RelationManager is better? Would love some advice please My latest attempt is with a relation-manager but that attempts to create new artwork which I don't want...I need to assign many artworks, visually to a parent exhibition.
43 replies
FFilament
Created by bionary on 6/10/2023 in #❓┊help
Native Back Button leads to Broken Resource Limits
1. Set an admin resource table to something other than the default: "50 per page" for example 2. Click to view an item 3. Click native back button 4. Unexpected results on the admin table The page goes back to the admin resource list, displays "50 per page" at the bottom of the table, but only shows 10 records. Is there a fix for this? Thanks !
6 replies
FFilament
Created by bionary on 5/31/2023 in #❓┊help
Create & create another - reuse fields
When clicking the "Create & create another" button is there a way to reuse some of the input fields? (Have some chosen inputs default to the previous value that was just saved) I have a massive number of fields and many of them could benefit by retaining the same info.
10 replies
FFilament
Created by bionary on 4/21/2023 in #❓┊help
Sharing form() Resources ?
I was wondering if I could load another resource's $form into the --simple modal of a different resource? Use case: I can quickly access resource views quickly such as comment threads (from dash) related to other models...rather then having to go to that resource table, find the record with comments, click through...etc.. Having a table of comments is not very useful, but clicking through to the record where all of the comments exist on the related model is more useful I believe. From my attempts the trick seems to be associating the model record with the form, while inside of another resource. Not sure how to do this. An example from my code is:
//IllustrationSketchesRelationManager::form holds the form fields AND Model-Record I'd like to reuse.

public static function form(Form $form): Form
{
return IllustrationSketchesRelationManager::form(new \Filament\Resources\Form();
}
//IllustrationSketchesRelationManager::form holds the form fields AND Model-Record I'd like to reuse.

public static function form(Form $form): Form
{
return IllustrationSketchesRelationManager::form(new \Filament\Resources\Form();
}
I'm referencing the form above, but it obviously has no awareness of the correct model. Are there any methods that allow passing in the correct model/record? OR maybe I'm thinking about this incorrectly, or it's quite possible that this is not even possible with filament.
69 replies
FFilament
Created by bionary on 4/13/2023 in #❓┊help
Complete headings set with RichEditor (trix)?
Anybody know any options for adding more headings to filament's RichEditor (Trix) form input? Right now the only options are "heading" and "Subheading" which resolve to h2,h3 tags. I like the trix editor but would like to have h4, h5 as an option as well. Thanks.
9 replies
FFilament
Created by bionary on 4/4/2023 in #❓┊help
How to filter table based on grandparent relationships?
Say I have relationship structure: Project > Category > Article > Illustration I'm interested in filtering by Project when viewing the Illustration list. I have set up all my belongsTo() relationships. It's simple when using pure Laravel; to traverse back up the parents:
$illustration->article->category->project;

//works great!
$illustration->article->category->project;

//works great!
But in filament I'm not sure how to handle this type of filtering. I realize this would be easy if Laravel handled nested relationships but apparently it does not 😦
I also realized that you can do some filament stuff for Form: Selects in forms like this:
Group::make([
Group::make([
Group::make([
Select::make('project_id')
->relationship('project','name')
->reactive()
->required()
])->relationship('category'),
])->relationship('article'),
]),
Group::make([
Group::make([
Group::make([
Select::make('project_id')
->relationship('project','name')
->reactive()
->required()
])->relationship('category'),
])->relationship('article'),
]),
That admittedly works for forms, but I cannot seem to find a similar / suitable solution for filtering table data based on grandparent relationships. (I also experimented with the belongs-to-through package, but that doesn't seem to work either) Any help would be appreciated, thanks!
11 replies
FFilament
Created by bionary on 3/29/2023 in #❓┊help
Conditionally Prevent Record Edit?
I know I can disable form inputs one-by-one via ->disabled(...). But, what if I wish to prevent editing for entire page based on a field in the model. Like if $record->is_locked == true ? If would be great to prevent the edit page from opening or in the least open to a view page.
Thanks in advance for any guidance!
9 replies
FFilament
Created by bionary on 3/25/2023 in #❓┊help
Additional Info Fields in Form
What is the best way to go about adding supplemental data fields to a form? But the catch is, it shouldn't be handled as form fields. (not saved) I often find that including stuff like parent-relationship info in or near the form is helpful sometimes. I tried using ViewField and making sure that my view had non-form elements in it, but when upon saving the form, filament is expecting a saved data field for "parent_properties" as setup below.
ViewField::make('parent_properties')->view('filament.forms.components.text-display')
ViewField::make('parent_properties')->view('filament.forms.components.text-display')
//text-display.blade.php
<x-dynamic-component
:component="$getFieldWrapperView()"
:id="$getId()"
:label="$getLabel()"
:label-sr-only="$isLabelHidden()"
:helper-text="$getHelperText()"
:hint="$getHint()"
:hint-action="$getHintAction()"
:hint-color="$getHintColor()"
:hint-icon="$getHintIcon()"
:required="$isRequired()"
:state-path="$getStatePath()"
>

<p>Project: {{$this->record->article->project->name}}</p>
<p>Category: {{$this->record->article->category->path}}</p>
<p>Article: {{$this->record->article->title}}</p>
<p>Contractor: {{$this->record->contractor->name}}</p>
</x-dynamic-component>
//text-display.blade.php
<x-dynamic-component
:component="$getFieldWrapperView()"
:id="$getId()"
:label="$getLabel()"
:label-sr-only="$isLabelHidden()"
:helper-text="$getHelperText()"
:hint="$getHint()"
:hint-action="$getHintAction()"
:hint-color="$getHintColor()"
:hint-icon="$getHintIcon()"
:required="$isRequired()"
:state-path="$getStatePath()"
>

<p>Project: {{$this->record->article->project->name}}</p>
<p>Category: {{$this->record->article->category->path}}</p>
<p>Article: {{$this->record->article->title}}</p>
<p>Contractor: {{$this->record->contractor->name}}</p>
</x-dynamic-component>
I know I can use one of the mutateData...functions to strip the form input prior to being saved, but I can see this getting sloppy and bloated quickly. What is a better approach? Thanks!
6 replies
FFilament
Created by bionary on 3/18/2023 in #❓┊help
Form Columns Variable/Dynamic
To my chagrin there is no closure available to Form's columns I'm using Group/Sections with ->column() And really need the ability to change the column numbers dynamically. Any idea how to set a form column value dynamically?
37 replies