ElCoco
ElCoco
FFilament
Created by ElCoco on 9/9/2024 in #❓┊help
Where to find Filament color styles for default themes
I am integrating my own livewire components into a filment dashboard. I am struggling to find the color classes filaments uses for the default dark and bright themes. All I found in the docs is this: https://filamentphp.com/docs/3.x/support/colors Which doesn't link to any default colors (other than the examples) I am interested in doing something like: <tr class="{{ $index % 2 === 0 ? 'bg-filament-default' : 'bg-filament-default-highlight' }}"> I tried looking in the vendor folder but I just found gigantic .js files regarding to themes that are hard to make any sense off 😛 I can eye ball the tailwindcss color and use those but would be nice if there is already a bg-class for that.
3 replies
FFilament
Created by ElCoco on 9/7/2024 in #❓┊help
Showing notifications as modals
Sometimes I want to ensure that the user gets the notification and acknowledge it. There is a way to open a notification as a modal with just one button "OK"? If there isn't, can I open a modal on demand? On the filament docs all the modals are highly tied to forms and actions, I couldn't find a way to do something like Filament::ShowModal("My message here", "OK") I guess I could use a livewire modal, but I want the modal to fit with the look and feel of filament UI out of the box.
11 replies
FFilament
Created by ElCoco on 9/28/2023 in #❓┊help
Sending a form when pressing enter
I have this form:
protected function promptForm(Form $form): Form
{
return $form
->schema([
FilamentForms\Select::make('targetBot')
->label('Bots available')
->searchable()
->options(Prompt::all()->pluck('name', 'id'))
->default(Prompt::where('is_active', true)->pluck('name', 'id')),
FilamentForms\TextInput::make('prompt')
->label('Start Conversation')
->autofocus()
->autocomplete(false),
]);
}
protected function promptForm(Form $form): Form
{
return $form
->schema([
FilamentForms\Select::make('targetBot')
->label('Bots available')
->searchable()
->options(Prompt::all()->pluck('name', 'id'))
->default(Prompt::where('is_active', true)->pluck('name', 'id')),
FilamentForms\TextInput::make('prompt')
->label('Start Conversation')
->autofocus()
->autocomplete(false),
]);
}
If I remove the Select component it works as intended, that is, it will send the form when I press enter while focused on the TextInput. But if the Select is present it does nothing. I do not have any validation going on that I am aware off... Here is my blade:
<div class="mx-auto p-4 sm:p-6 lg:p-8 grid grid-cols-5 gap-4">
<div class="col-span-1">
{{ $this->conversationsList }}
</div>
@if ($this->hasActivePrompt)
<div class="col-span-4">
<form wire:submit="sendPrompt">
@csrf
{{ $this->promptForm }}
</form>
<div wire:loading>
Loading...
</div>
</div>
@else
<div class="col-span-4">
No active prompt found.
</div>
@endif
</div>
<div class="mx-auto p-4 sm:p-6 lg:p-8 grid grid-cols-5 gap-4">
<div class="col-span-1">
{{ $this->conversationsList }}
</div>
@if ($this->hasActivePrompt)
<div class="col-span-4">
<form wire:submit="sendPrompt">
@csrf
{{ $this->promptForm }}
</form>
<div wire:loading>
Loading...
</div>
</div>
@else
<div class="col-span-4">
No active prompt found.
</div>
@endif
</div>
3 replies
FFilament
Created by ElCoco on 9/11/2023 in #❓┊help
Why this RepeatableEntry code doesn't work as expected
public function conversationsList(Infolist $infolist): Infolist
{
$user = User::find(auth()->id());
$conversations = $user->conversations()->select('id', 'name')->get()->toArray();
// dd($conversations);
return $infolist
->schema([
FilamentInfolists\RepeatableEntry::make('conversations')
->hiddenLabel(true)
->schema([
FilamentInfolists\TextEntry::make('id')
->hiddenLabel()
->action(Action::make('select')
->action(function (int $id) {
dd($id);
})
),
FilamentInfolists\TextEntry::make('name')
->hiddenLabel()
])
])
->state([
'conversations' => $conversations
])
->columns(1);
}
public function conversationsList(Infolist $infolist): Infolist
{
$user = User::find(auth()->id());
$conversations = $user->conversations()->select('id', 'name')->get()->toArray();
// dd($conversations);
return $infolist
->schema([
FilamentInfolists\RepeatableEntry::make('conversations')
->hiddenLabel(true)
->schema([
FilamentInfolists\TextEntry::make('id')
->hiddenLabel()
->action(Action::make('select')
->action(function (int $id) {
dd($id);
})
),
FilamentInfolists\TextEntry::make('name')
->hiddenLabel()
])
])
->state([
'conversations' => $conversations
])
->columns(1);
}
The list shows up properly, but when I click in the action I get: An attempt was made to evaluate a closure for [Filament\Infolists\Components\Actions\Action], but [$id] was unresolvable. I am trying to get the value of 'id' in the current component action. I also tried other stuff like $state or injecting Get and some desperate random stuff...Nothing seems to work. The only thing that gives sings if working is:
->action(function (array $data) {
dd($data);
})
->action(function (array $data) {
dd($data);
})
But this gives me an empty array.
5 replies
FFilament
Created by ElCoco on 9/6/2023 in #❓┊help
RepeatableEntry, state array data and suffix actions. How to get the repeatable state in the action.
I have this infolist, $this->conversation->history returns an array (stored as JSON in the DB) :
public function conversationInfolist(Infolist $infolist): Infolist
{
return $infolist
// ->record($this->conversation)
->state([
'history' => $this->conversation->history
])
->schema([
FilamentInfolists\RepeatableEntry::make('history')
->hiddenLabel(true)
->schema([
FilamentInfolists\TextEntry::make('conversation.input_text')
->hiddenLabel(true),
FilamentInfolists\TextEntry::make('conversation.output_text')
->label(' ')
->suffixActions([
Action::make('thumbsup')
->icon('heroicon-m-hand-thumb-up')
->action(function (Get $get) {
dd($get('something'));
}),
Action::make('thumbsdown')
->icon('heroicon-m-hand-thumb-down')
->action(function (Conversation $record) {
})

])
])
->contained(true)
])
->columns(1);
}
public function conversationInfolist(Infolist $infolist): Infolist
{
return $infolist
// ->record($this->conversation)
->state([
'history' => $this->conversation->history
])
->schema([
FilamentInfolists\RepeatableEntry::make('history')
->hiddenLabel(true)
->schema([
FilamentInfolists\TextEntry::make('conversation.input_text')
->hiddenLabel(true),
FilamentInfolists\TextEntry::make('conversation.output_text')
->label(' ')
->suffixActions([
Action::make('thumbsup')
->icon('heroicon-m-hand-thumb-up')
->action(function (Get $get) {
dd($get('something'));
}),
Action::make('thumbsdown')
->icon('heroicon-m-hand-thumb-down')
->action(function (Conversation $record) {
})

])
])
->contained(true)
])
->columns(1);
}
I need to have the current state of the repeater in the thumbsup/thumbsdown actions. I tried to inject the $state variable and it throws the messsage:
An attempt was made to evaluate a closure for [Filament\Infolists\Components\Actions\Action], but [$state] was unresolvable.
An attempt was made to evaluate a closure for [Filament\Infolists\Components\Actions\Action], but [$state] was unresolvable.
Injecting Get as you see in the example gives:
Typed property Filament\Forms\Components\Component::$container must not be accessed before initialization
Typed property Filament\Forms\Components\Component::$container must not be accessed before initialization
Someone has any idea of what should I do to get some state out of the repeatable. Actually getting just the INDEX of the array in the repeater loop would already make me pretty happy...
4 replies
FFilament
Created by ElCoco on 9/3/2023 in #❓┊help
Save to DB after deleting a repeater element
I am implementing a ChatGPT-like UI. I use a Repeater to populate the list of conversations. When I press the delete icon it deletes properly the element from the array but I would have to press Submit to save the modified list into the DB. What I want is to save the array immediately after pressing the Delete button (actually this control ideally doesn't even have a submit button). I played a bit with deleteAction object (https://filamentphp.com/docs/3.x/forms/fields/repeater#customizing-the-repeater-action-objects) but it seems it can just setup the action in specific ways instead of running code after pressing the delete button. This is my form:
protected function getFormSchema(): array
{
// dd($this->conversation);
return [
FilamentForms\Repeater::make('history')
->schema([
FilamentForms\TextInput::make('name')
->readOnly(true)
->label('')
])
->addable(false)
->model($this->conversation)
->statePath('data')
];
}
protected function getFormSchema(): array
{
// dd($this->conversation);
return [
FilamentForms\Repeater::make('history')
->schema([
FilamentForms\TextInput::make('name')
->readOnly(true)
->label('')
])
->addable(false)
->model($this->conversation)
->statePath('data')
];
}
5 replies
FFilament
Created by ElCoco on 8/31/2023 in #❓┊help
Can a suffixAction be triggered by pressing enter?
I have this form in a filament v3 Page:
public function form(Form $form): Form
{
return $form
->schema([
Components\TextInput::make('stuff')
->suffixAction(
Action::make('sendStuff')
->icon('heroicon-m-clipboard')
->action(function () {
$response = "Action triggered!"
})
),
Components\Textarea::make('response')
->rows(10),
]);
}
public function form(Form $form): Form
{
return $form
->schema([
Components\TextInput::make('stuff')
->suffixAction(
Action::make('sendStuff')
->icon('heroicon-m-clipboard')
->action(function () {
$response = "Action triggered!"
})
),
Components\Textarea::make('response')
->rows(10),
]);
}
I was expecting that the suffixAction will also be triggered by pressing the Enter key but is not the case. I could not find any mention to something like this in the Docs. I guess I am missing something very basic here...
5 replies