Altffenser
Altffenser
FFilament
Created by Altffenser on 7/21/2024 in #❓┊help
Impement Action to show modal at custom page in Widget
Hello everyone, I'm trying to implement a Calendar with basic functionality but seems to be complicated work with Modals. Trying to add a modal for view event details on clic on it, the modal isn't displayed. I'm using GuavaCZ/Calendar package (still in develop) part of code:
use Filament\Actions\Action;
.
.
.
public function onEventClick(array $info = [], ?string $action = null): void
{
// Show detailed event info
Action::make()
->record(Commission::find(1))
->form([
TextInput::make('name')
->required()
->maxLength(255),
// ...
])->action(function (array $data): void {
dd($data);
});

}
use Filament\Actions\Action;
.
.
.
public function onEventClick(array $info = [], ?string $action = null): void
{
// Show detailed event info
Action::make()
->record(Commission::find(1))
->form([
TextInput::make('name')
->required()
->maxLength(255),
// ...
])->action(function (array $data): void {
dd($data);
});

}
This code is a test, how can I make it work? V3 with panels (new project) Some help is appreciated.
2 replies
FFilament
Created by Altffenser on 10/24/2023 in #❓┊help
Include prefix as part of text input.
How can I do to include the prefix on TextInput for saving in database? My code:
TextInput::make('title')
->name('title')
->helperText(new HtmlString('Please <b style="color:red">do not</b> include the word indicating the type of event selected, it will be added automatically.'))
->label('Event title')
->prefix(function (Get $get): string {
return Event\Type::find($get('event_type_id'))->name ?? '';
})
TextInput::make('title')
->name('title')
->helperText(new HtmlString('Please <b style="color:red">do not</b> include the word indicating the type of event selected, it will be added automatically.'))
->label('Event title')
->prefix(function (Get $get): string {
return Event\Type::find($get('event_type_id'))->name ?? '';
})
I always thought it was included but it is not. Thank you for help. 😊
5 replies
FFilament
Created by Altffenser on 10/23/2023 in #❓┊help
Why does this evaluation not take effect on a component?
I have this function inside ->disabled() method but isn't taking effect.
Toggle::make('is_private')
->onColor('success')
->onIcon('tabler-spy')
->label('Privado')
->live(true)
->disabled(fn(Get $get) => $get('session_commission_id') == '2')
->columnSpan([
'sm' => 1
]),
Toggle::make('is_private')
->onColor('success')
->onIcon('tabler-spy')
->label('Privado')
->live(true)
->disabled(fn(Get $get) => $get('session_commission_id') == '2')
->columnSpan([
'sm' => 1
]),
This is part of a action form with CreateAction::class, in any case, is there any way to obtain a object of components (or individual) and handle it separately?
2 replies
FFilament
Created by Altffenser on 10/22/2023 in #❓┊help
$container must not be accessed before initialization
What happen with this error? I'm trying to set TextInput "title" component at updated() method but this error is showed.
updated(Set $set) {
$set('title', $this->title)
}
updated(Set $set) {
$set('title', $this->title)
}
Complete error: Typed property Filament\Forms\Components\Component::$container must not be accessed before initialization I need to set title when any field is changed. I used to use afterStateUpdated()method but this not work in "live".
4 replies
FFilament
Created by Altffenser on 10/20/2023 in #❓┊help
Conditionally create non-editable fields
There are a function that create a "TextInput" no editable for the user? I would like to send "generated" data based on others fields, then, put it at non editable field like *username * based on real user name. Disabled fields cannot be sent due to their own disabled status. How can I achieve this function?
5 replies
FFilament
Created by Altffenser on 10/19/2023 in #❓┊help
afterStateUpdate() with delay on select component
Hello guys, I have created a form with a specific operation that so far my development experience has been perfect and only with this small detail. My intention is to form the "Title" field from selector menus, the detail is that there is a delay when having selected an option; the "title" field remains with the previous value. my afterStateUpdate() method:
->live(false)
->afterStateUpdated(function (Set $set) {
$commission = Commission::find($this->session_commission_id);
$set('title', 'Session ' . ($this->session_type == 1
? "Special "
: ($this->session_type == 2
? "Ext. "
: "Ord. ")) .
$this->session_consecutive . " " . ($commission?->type == 1
? "of the commission " . ($commission?->id != 19 ? 'of '
: '') . $commission?->name
: ($commission?->type == 2
? "committee " . $commission?->name
: "of " . $commission?->name)));
})
->live(false)
->afterStateUpdated(function (Set $set) {
$commission = Commission::find($this->session_commission_id);
$set('title', 'Session ' . ($this->session_type == 1
? "Special "
: ($this->session_type == 2
? "Ext. "
: "Ord. ")) .
$this->session_consecutive . " " . ($commission?->type == 1
? "of the commission " . ($commission?->id != 19 ? 'of '
: '') . $commission?->name
: ($commission?->type == 2
? "committee " . $commission?->name
: "of " . $commission?->name)));
})
My Select component:
Select::make('session_commission_id')
->options([
'1' => 'Any type of commission',
'2' => 'Other type of commission',
'3' => 'Another type of commission',
])
->searchable()
->preload()
->native(false)
->label('Commission')
->required()
->rules('required')
->live(true)
->afterStateUpdated(function (Get $get) {
$this->session_commission_id = $get('session_commission_id');
}),
Select::make('session_commission_id')
->options([
'1' => 'Any type of commission',
'2' => 'Other type of commission',
'3' => 'Another type of commission',
])
->searchable()
->preload()
->native(false)
->label('Commission')
->required()
->rules('required')
->live(true)
->afterStateUpdated(function (Get $get) {
$this->session_commission_id = $get('session_commission_id');
}),
Is there something I am doing wrong, or is the behavior I expect my component to take not possible? Thanks!
2 replies
FFilament
Created by Altffenser on 10/16/2023 in #❓┊help
How to create a modal form
I try to read the documentation but it is not clear, I don't understand how to implement Action::make() in Form class if:
public function form(Form $form): Form
{
return $form
->schema([

])
->statePath('data')
->model(Event::class);
}
public function form(Form $form): Form
{
return $form
->schema([

])
->statePath('data')
->model(Event::class);
}
Form returns this. Action::make() is a little different. https://filamentphp.com/docs/3.x/actions/modals#modal-forms
Action::make('updateAuthor')
->form([
Select::make('authorId')
->label('Author')
->options(User::query()->pluck('name', 'id'))
->required(),
])
->action(function (array $data, Post $record): void {
$record->author()->associate($data['authorId']);
$record->save();
})
Action::make('updateAuthor')
->form([
Select::make('authorId')
->label('Author')
->options(User::query()->pluck('name', 'id'))
->required(),
])
->action(function (array $data, Post $record): void {
$record->author()->associate($data['authorId']);
$record->save();
})
I created a component with the command : php artisan make:livewire-form Foo Any assistance is welcome, thanks!
3 replies
FFilament
Created by Altffenser on 10/15/2023 in #❓┊help
SPA mode for standalone projects.
Hello again. After having installed the Filament table builder in a new project with Livewire and Laravel Breeze; I have the following error, and that is that when loading the page after logging in, the component works fine, but when I navigate to /profile and then back to /dashboard (where the table is located) and that's when the errors occur. By default, Laravel Breeze uses <livewire:navigation> to navigate between pages as a SPA. I know Filament uses Livewire v3, but in some support topics on Stackoverflow they point out that the problem is *Dom Diffing. * The error: Uncaught Could not find Livewire component in DOM tree Then Alpine register another. Alpine Expression Error: undefined Expression: "selectFormComponent({ canSelectPlaceholder: true, isHtmlAllowed: false, getOptionLabelUsing: async () => { return await ... and much more from this error. Some context in this post https://stackoverflow.com/questions/72335516/cannot-find-parent-element-in-dom-tree-containing-attribute-wireid Any solution? 😦
3 replies
FFilament
Created by Altffenser on 10/14/2023 in #❓┊help
Text to case...
Hello devs! I am looking for a function that convert text to uppercase (or title case) in TextInput or TextArea, you know any implementation to do it? I usually do it with javascript but I can't find a way to inject JS into the component.
8 replies
FFilament
Created by Altffenser on 10/13/2023 in #❓┊help
Installing database notifications on existing project
I'm trying to do that but I see that I don't have any assets published in my views directory and only javascript assets are published. I have checked in vendor/filament/notifications/views and there are still many assets that have not been published. Also, in the documentation it mentions that the view must be registered in a Service Provider, but it doesn't mention in which one, I tried to do it in the AppServiceProvider but it doesn't work because it shows the error "Undefined variable $unreadNotificationsCount". Someone please guide me :S
22 replies