martin-ro
martin-ro
FFilament
Created by martin-ro on 12/22/2023 in #❓┊help
Default Select
When I use a toggle to hide a select the default only works when creating a record. When editing the default is always the first option
Toggle::make('showStatus')->live(),

Select::make('status')
->default('published')
->selectablePlaceholder(false)
->visible(fn (Get $get) => $get('showStatus'))
->options([
'draft' => 'Draft',
'reviewing' => 'Reviewing',
'published' => 'Published',
]),
Toggle::make('showStatus')->live(),

Select::make('status')
->default('published')
->selectablePlaceholder(false)
->visible(fn (Get $get) => $get('showStatus'))
->options([
'draft' => 'Draft',
'reviewing' => 'Reviewing',
'published' => 'Published',
]),
5 replies
FFilament
Created by martin-ro on 12/11/2023 in #❓┊help
Updating record from extraItemsAction in Builder
I have a builder with an extraItemAction
$this->extraItemActions([
Action::make('toggleVisibility')
->icon(fn ($state, array $arguments) => $state[$arguments['item']]['data']['visible'] ? 'heroicon-o-eye' : 'heroicon-o-eye-slash')
->action(function (array $arguments, Builder $component) {
$state = $component->getState();
$state[$arguments['item']]['data']['visible'] = ! $state[$arguments['item']]['data']['visible'];

$component->state($state);
}),
...
$this->extraItemActions([
Action::make('toggleVisibility')
->icon(fn ($state, array $arguments) => $state[$arguments['item']]['data']['visible'] ? 'heroicon-o-eye' : 'heroicon-o-eye-slash')
->action(function (array $arguments, Builder $component) {
$state = $component->getState();
$state[$arguments['item']]['data']['visible'] = ! $state[$arguments['item']]['data']['visible'];

$component->state($state);
}),
...
How can I update the record after the action was fired?
3 replies
FFilament
Created by martin-ro on 11/3/2023 in #❓┊help
Update a KeyValue field
in V2 I was able to update a KeyValue field like so:
Forms\Components\TextInput::make('test1')
->live()
->afterStateUpdated(function (Forms\Get $get, Forms\Set $set) {
$set('test2', [
'txt' => $get('test1'),
]);
}),

Forms\Components\KeyValue::make('test2')
->default(['txt' => '']),
Forms\Components\TextInput::make('test1')
->live()
->afterStateUpdated(function (Forms\Get $get, Forms\Set $set) {
$set('test2', [
'txt' => $get('test1'),
]);
}),

Forms\Components\KeyValue::make('test2')
->default(['txt' => '']),
But that doesn't seem to work anymore... I can't figure out how to update the values :/
2 replies
FFilament
Created by martin-ro on 8/18/2023 in #❓┊help
Accessing $records in hintAction
I have a form field and would like to access the record I'm editing in a hint action...
Textarea::make()
->rows(3)
->hintAction(
Forms\Components\Actions\Action::make('generate_title')
->icon('heroicon-o-arrow-path')
->action(function (?Role $record, Set $set) {
ray($record);
...
Textarea::make()
->rows(3)
->hintAction(
Forms\Components\Actions\Action::make('generate_title')
->icon('heroicon-o-arrow-path')
->action(function (?Role $record, Set $set) {
ray($record);
...
Record is null here... what's the right way to access the record? Thanks!
5 replies