Crylar
Crylar
FFilament
Created by Crylar on 9/10/2024 in #❓┊help
Conditional component builder
Hello guys, I was wondering if there is a better way to write this:
Tables\Columns\TextColumn::make('starts_at')
->label('Status')
->alignCenter()
->badge()
->color(
fn (PreOrderInvitation $record) => $record->starts_at->isFuture()
? Color::Orange
: Color::Green
)
->icon(fn (PreOrderInvitation $record) => $record->starts_at->isFuture() ? 'gmdi-schedule-o' : false)
->tooltip(fn (PreOrderInvitation $record) => $record->starts_at->format('Y-m-d H:i'))
->formatStateUsing(fn (PreOrderInvitation $record) => $record->starts_at->isFuture() ? 'scheduled' : 'sent'),
Tables\Columns\TextColumn::make('starts_at')
->label('Status')
->alignCenter()
->badge()
->color(
fn (PreOrderInvitation $record) => $record->starts_at->isFuture()
? Color::Orange
: Color::Green
)
->icon(fn (PreOrderInvitation $record) => $record->starts_at->isFuture() ? 'gmdi-schedule-o' : false)
->tooltip(fn (PreOrderInvitation $record) => $record->starts_at->format('Y-m-d H:i'))
->formatStateUsing(fn (PreOrderInvitation $record) => $record->starts_at->isFuture() ? 'scheduled' : 'sent'),
I do sometimes find myself repeating same code when I need to conditionally define particular values... is there a better way, where I could just check for a single condition and based on this set needed parameters.
2 replies
FFilament
Created by Crylar on 6/22/2024 in #❓┊help
Icon or Tooltip on the column header
Hi, I know you are able to have tooltip on a cell but is it possible to have one right on the column header? I would like to add some sort of icon (?) mark to the column header, that would display some hint / tooltip when user clicks / hovers over it. How I could achieve this sort of behaviour? Thanks.
2 replies
FFilament
Created by Crylar on 9/29/2023 in #❓┊help
Table action button is not getting updated after action executed
In v2 the color, label, disabled used to update after the action finished but this is different in v3. How can I bring the old behaviour and re-render the table?
Actions\Action::make('activate')
->button()
->disabled(fn (Arena $record) => $record->id == $activeVenueId)
->label(fn (Arena $record) => $record->id == $activeVenueId ? __('filament/venues.active') : __('filament/venues.activate'))
->color(fn (Arena $record) => $record->id == $activeVenueId ? 'gray' : 'success')
->action(function (Arena $record) {
Auth::user()->switchArena($record);

Notification::make()
->title(new HtmlString('<span class="font-bold underline">'. $record->title .'</span> is active now!'))
->success()
->send();
})
Actions\Action::make('activate')
->button()
->disabled(fn (Arena $record) => $record->id == $activeVenueId)
->label(fn (Arena $record) => $record->id == $activeVenueId ? __('filament/venues.active') : __('filament/venues.activate'))
->color(fn (Arena $record) => $record->id == $activeVenueId ? 'gray' : 'success')
->action(function (Arena $record) {
Auth::user()->switchArena($record);

Notification::make()
->title(new HtmlString('<span class="font-bold underline">'. $record->title .'</span> is active now!'))
->success()
->send();
})
2 replies
FFilament
Created by Crylar on 7/25/2023 in #❓┊help
How can I get typed value from TextInput with Mask?
I have the following code and would like to get a typed value but : symbol gets missing right now.
...Arr::map(['opening_hour', 'closing_hour'], fn ($name) => Forms\Components\TextInput::make($name)
->mask(fn (Forms\Components\TextInput\Mask $mask) => $mask
->patternBlocks([
'h' => fn (Forms\Components\TextInput\Mask $mask) => $mask
->range()
->from(0)
->to(23)
->maxValue(23)
->maxLength(2),

'm' => fn (Forms\Components\TextInput\Mask $mask) => $mask
->range()
->from(0)
->to(59)
->maxValue(59)
->maxLength(2),
])
->pattern('00:00')
)
->disableLabel()
...Arr::map(['opening_hour', 'closing_hour'], fn ($name) => Forms\Components\TextInput::make($name)
->mask(fn (Forms\Components\TextInput\Mask $mask) => $mask
->patternBlocks([
'h' => fn (Forms\Components\TextInput\Mask $mask) => $mask
->range()
->from(0)
->to(23)
->maxValue(23)
->maxLength(2),

'm' => fn (Forms\Components\TextInput\Mask $mask) => $mask
->range()
->from(0)
->to(59)
->maxValue(59)
->maxLength(2),
])
->pattern('00:00')
)
->disableLabel()
2 replies
FFilament
Created by Crylar on 5/11/2023 in #❓┊help
Is there a way to have a confirmation dialogue on ToggleColumn on table?
I was looking for a confirmation modal for this component but I could not find any? Is it supported, or how could I achieve this?
Tables\Columns\ToggleColumn::make('availability')
->onColor('success')
->getStateUsing(fn (Product $record) => $record->status == ProductStatus::ACTIVE)
->updateStateUsing(function (Product $record, bool $state) {
$record->update([
'status' => $state
? ProductStatus::ACTIVE
: ProductStatus::PAUSED
]);
}),
Tables\Columns\ToggleColumn::make('availability')
->onColor('success')
->getStateUsing(fn (Product $record) => $record->status == ProductStatus::ACTIVE)
->updateStateUsing(function (Product $record, bool $state) {
$record->update([
'status' => $state
? ProductStatus::ACTIVE
: ProductStatus::PAUSED
]);
}),
12 replies
FFilament
Created by Crylar on 5/10/2023 in #❓┊help
Is it possible to update state of a single row in the records table?
I have the following toggle button on a table, and update Eloquent model based on the $state. The problem I am facing is that all of Toggle buttons on the table re-render right now and create some unpleasant experience. How can I limit this to only a single row?
Tables\Columns\ToggleColumn::make('availability')
->onColor('success')
->getStateUsing(fn (Product $record) => $record->status == ProductStatus::ACTIVE)
->updateStateUsing(function (Product $record, bool $state) {
$record->update([
'status' => $state
? ProductStatus::ACTIVE
: ProductStatus::PAUSED
]);
}),
Tables\Columns\ToggleColumn::make('availability')
->onColor('success')
->getStateUsing(fn (Product $record) => $record->status == ProductStatus::ACTIVE)
->updateStateUsing(function (Product $record, bool $state) {
$record->update([
'status' => $state
? ProductStatus::ACTIVE
: ProductStatus::PAUSED
]);
}),
49 replies
FFilament
Created by Crylar on 5/7/2023 in #❓┊help
Is it possible to have some sort of tabs / buttons above the table?
I would like to list some of items above the table, and show different results on the table when someone clicks on one or another. Is there an easy way to achieve this?
22 replies
FFilament
Created by Crylar on 5/6/2023 in #❓┊help
How can I get Resource Form inside the action ->form ?
I have the following code:
Tables\Actions\ReplicateAction::make('replicate')
->iconButton()
->excludeAttributes(['category_title'])
->form(function () {

})
Tables\Actions\ReplicateAction::make('replicate')
->iconButton()
->excludeAttributes(['category_title'])
->form(function () {

})
I was wondering how would I get data from
public static function form(Form $form): Form
{
return $form
public static function form(Form $form): Form
{
return $form
I could do
static::form(...)
static::form(...)
but not sure what to input as a Form variable here. Please advice what's the best approach in reusing form schema. Thanks.
9 replies
FFilament
Created by Crylar on 5/6/2023 in #❓┊help
How to disable label for the action button?
I was trying to do this using
Tables\Actions\EditAction::make()->disableLabel()
Tables\Actions\EditAction::make()->disableLabel()
but it looks like to ignore this and still shows the label. Is it a bug or a feature?
7 replies
FFilament
Created by Crylar on 5/2/2023 in #❓┊help
Is it possible to change table filter icon or trigger with a button?
Users find it very difficult to click on mobile devices, so was wondering if it's possible to maybe trigger filter popup with a button? Also maybe it's possible to open filter modal in a centre of the screen?
29 replies
FFilament
Created by Crylar on 5/2/2023 in #❓┊help
How can I access pivot relationship in repeater?
I have a belongsToMany relationship but for some reason the pivot is lost. I have fields with same names in both pivot and ref table. I have tried to use loadStateFromRelationshipsUsing instead of relationship but then I get wrong $record model in Repeater schema... please advice.
6 replies
FFilament
Created by Crylar on 5/1/2023 in #❓┊help
Is it possible to change action on row click?
I was wondering if it's possible to trigger another action when user clicks on a row? e.g. I would like to have view action instead of edit action on row click.
13 replies
FFilament
Created by Crylar on 5/1/2023 in #❓┊help
Is it possible to enable particular component during view?
I have tried to do disabled(false) but the component remains disabled. Is it possible to override this in a view?
Forms\Components\Toggle::make('delivered')
->disableLabel()
->disabled(false)
Forms\Components\Toggle::make('delivered')
->disableLabel()
->disabled(false)
33 replies
FFilament
Created by Crylar on 5/1/2023 in #❓┊help
How to customise title in SelectFilter loaded via relationship?
I have the following filter and would love to concat title with prefix field. How it's possible to modify the results?
Tables\Filters\SelectFilter::make('pod')
->multiple()
->searchable()
->relationship('pod', 'title'),
Tables\Filters\SelectFilter::make('pod')
->multiple()
->searchable()
->relationship('pod', 'title'),
2 replies
FFilament
Created by Crylar on 5/1/2023 in #❓┊help
Is it possible to hide some form elements when calling via view action?
I would like to somehow detect that form was loaded by using view action and modity the form layout slightly.
8 replies
FFilament
Created by Crylar on 5/1/2023 in #❓┊help
What are my options to use repeater component as collapsible element inside table?
I would like to have products listed inside collapsible panel on a table with some actions attached to each repeater item but I am not sure if it's possible to mix table and form components, or custom is the only solution here?
6 replies
FFilament
Created by Crylar on 5/1/2023 in #❓┊help
How can I update a form input on action?
I have action button on edit page and would like to update a particular input on edit form. How can I do this?
Actions\Action::make('status.confirm')
->button()
->action(function () {
if ($this->record->status == OrderStatus::PAID) {
$this->record->status = OrderStatus::CONFIRMED;
$this->record->save();
}
}),
Actions\Action::make('status.confirm')
->button()
->action(function () {
if ($this->record->status == OrderStatus::PAID) {
$this->record->status = OrderStatus::CONFIRMED;
$this->record->save();
}
}),
and field on the form right now
Forms\Components\Select::make('status')
->reactive()
->required(),
Forms\Components\Select::make('status')
->reactive()
->required(),
3 replies
FFilament
Created by Crylar on 4/28/2023 in #❓┊help
Is it possible to use hex color for Badge or Text column?
I have need of having more custom colours than just 5 (primary, secondary, danger, warning, success). I have tried to set extraAttributes but it only applies for an upper div.
1 replies
FFilament
Created by Crylar on 4/26/2023 in #❓┊help
Is it possible to refresh table content on action?
I have a custom action -
Tables\Actions\Action::make('status.confirm')
->button()
->label('Confirm Order')
->color('success')
->action(function (Order $record) {
$record->status = OrderStatus::CONFIRMED;
$record->save();
})->visible(fn (Order $record) => $record->status == OrderStatus::PAID),
Tables\Actions\Action::make('status.confirm')
->button()
->label('Confirm Order')
->color('success')
->action(function (Order $record) {
$record->status = OrderStatus::CONFIRMED;
$record->save();
})->visible(fn (Order $record) => $record->status == OrderStatus::PAID),
I would like to somehow trigger a table refresh to reflect a new update for the record.
4 replies
FFilament
Created by Crylar on 4/21/2023 in #❓┊help
Is it possible to sort by navigation group?
I know there is protected static ?int $navigationSort to sort items inside the navigation group but is there any property to define actual sort for navigation groups themselves?
8 replies