Pathros
Pathros
FFilament
Created by Pathros on 9/2/2024 in #❓┊help
Filament\FilamentManager::getUserName(): Return value must be of type string, null returned
How to fix it?
3 replies
FFilament
Created by Pathros on 8/16/2024 in #❓┊help
resource navigation
How to customize the notification message after updating a record on a custom edit page? I got the following
<?php

namespace App\Filament\Investigador\Resources\InfoSys\Proyectos\ProyectoResource\Pages;

use ...
class ConfirmarFechas extends EditRecord
{
protected static string $resource = ProyectoResource::class;
//Referencias:
//https://github.com/filamentphp/demo/blob/main/app/Filament/Resources/Shop/OrderResource.php
//https://demo.filamentphp.com/shop/orders/1/edit
public function form(Form $form): Form
{
return $form
->schema([
Group::make()
->schema([
Section::make(fn(Proyecto $proyecto) => $proyecto->titulo)
->schema(static::getDatesDetailsFormSchema())
->columns(3)
])
->columnSpan('full')
])
;
}

public static function getDatesDetailsFormSchema():array
{
return [
DatePicker::make('fecha_inicio')->label('Fecha de inicio')
->disabled()
,
DatePicker::make('fecha_termino')->label('Fecha de término')
->closeOnDateSelection()
->required()
->minDate(fn($get) => $get('fecha_inicio'))
,
];
}
}
<?php

namespace App\Filament\Investigador\Resources\InfoSys\Proyectos\ProyectoResource\Pages;

use ...
class ConfirmarFechas extends EditRecord
{
protected static string $resource = ProyectoResource::class;
//Referencias:
//https://github.com/filamentphp/demo/blob/main/app/Filament/Resources/Shop/OrderResource.php
//https://demo.filamentphp.com/shop/orders/1/edit
public function form(Form $form): Form
{
return $form
->schema([
Group::make()
->schema([
Section::make(fn(Proyecto $proyecto) => $proyecto->titulo)
->schema(static::getDatesDetailsFormSchema())
->columns(3)
])
->columnSpan('full')
])
;
}

public static function getDatesDetailsFormSchema():array
{
return [
DatePicker::make('fecha_inicio')->label('Fecha de inicio')
->disabled()
,
DatePicker::make('fecha_termino')->label('Fecha de término')
->closeOnDateSelection()
->required()
->minDate(fn($get) => $get('fecha_inicio'))
,
];
}
}
when I hit save, i get the default message through a notification, but how do I override the notification message text?
4 replies
FFilament
Created by Pathros on 8/14/2024 in #❓┊help
edit page
I have created a resource in another panel, but it's not appearing in the navigation menu of that panel. I don't have any policies in the models. I have tried
protected static bool $shouldSkipAuthorization = true;
protected static bool $shouldSkipAuthorization = true;
but it doesn't work. in the route list of php artisan route:list, I do see the new resource route names, however, I don't see the newly created resource in the navigation menu. If i type the url of the resource, I see not found. Any ideas how to debug it and fix it?
2 replies
FFilament
Created by Pathros on 8/7/2024 in #❓┊help
custom page edit: unable to find component
I have followed the instructions to build a custom edit page to edit some specific fields of a record in its simplest way:
<?php

namespace App\Filament\Investigador\Resources\Sica\ProyectoResource\Pages;

use App\Filament\Investigador\Resources\Sica\ProyectoResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;

class EditDates extends EditRecord
{
protected static string $resource = ProyectoResource::class;
}
<?php

namespace App\Filament\Investigador\Resources\Sica\ProyectoResource\Pages;

use App\Filament\Investigador\Resources\Sica\ProyectoResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;

class EditDates extends EditRecord
{
protected static string $resource = ProyectoResource::class;
}
And registered that page in the resource:
public static function getPages(): array
{
return [
'fechas'=>Pages\EditDates::route('/{record}/fechas'),
];
}
public static function getPages(): array
{
return [
'fechas'=>Pages\EditDates::route('/{record}/fechas'),
];
}
When I hit on the save or submit button, I get the following error:
Livewire\Exceptions\ComponentNotFoundException: Unable to find component: [app.filament.investigador.resources.sica.proyecto-resource.pages.edit-dates]
When I check the route list by typing php artisan route:list --name=filament:
GET|HEAD path/to/proyectos/{record}/fechas filament.investigador.resources.sica.proyectos.fechas › App\Filament…
GET|HEAD path/to/proyectos/{record}/fechas filament.investigador.resources.sica.proyectos.fechas › App\Filament…
it is indeed listed. Then how do I fix it? any ideas? What am I missing?
2 replies
FFilament
Created by Pathros on 8/7/2024 in #❓┊help
For a custom filament page to edit a specific eloquent model, what is the URL of that page?
I haven't found any explanation how to find out the URL of a custom edit page of an Eloquent model. Is the URL based on the namespace and class name and panel?
<?php

namespace App\Filament\Investigador\Pages\Proyectos;

use ...

class ConfirmarFechas extends Page implements HasForms
{
use InteractsWithFormActions;

protected static string $view = 'filament.investigador.pages.proyectos.confirmar-fechas';
protected static ?string $title = 'Confirmar fechas';

/** columns*/
public ?string $fecha_inicio = null;
public ?string $fecha_termino = null;

public function mount(Proyecto $proyecto): void
{
$this->form->fill($proyecto->toArray());
}
public function form(Form $form): Form
{
return $form
->schema([
DatePicker::make('fecha_inicio')->label('Fecha de inicio')
->required()
->closeOnDateSelection()
->reactive()
,
DatePicker::make('fecha_termino')->label('Fecha de término')
->required()
->closeOnDateSelection()
//Que la fecha mínima sea la elegida en la fecha de inicio: https://discord.com/channels/883083792112300104/1247978059743756329/1247990543187968142
->minDate(function (Get $get) {
return $get('fecha_inicio');
})
,
]);
}

public function getFormActions(): array
{
return [
Action::make('save')->action(
function (): void {
$this->update();
}
),
];
}

public function update()
{
dd('update the dates here');
}
}
<?php

namespace App\Filament\Investigador\Pages\Proyectos;

use ...

class ConfirmarFechas extends Page implements HasForms
{
use InteractsWithFormActions;

protected static string $view = 'filament.investigador.pages.proyectos.confirmar-fechas';
protected static ?string $title = 'Confirmar fechas';

/** columns*/
public ?string $fecha_inicio = null;
public ?string $fecha_termino = null;

public function mount(Proyecto $proyecto): void
{
$this->form->fill($proyecto->toArray());
}
public function form(Form $form): Form
{
return $form
->schema([
DatePicker::make('fecha_inicio')->label('Fecha de inicio')
->required()
->closeOnDateSelection()
->reactive()
,
DatePicker::make('fecha_termino')->label('Fecha de término')
->required()
->closeOnDateSelection()
//Que la fecha mínima sea la elegida en la fecha de inicio: https://discord.com/channels/883083792112300104/1247978059743756329/1247990543187968142
->minDate(function (Get $get) {
return $get('fecha_inicio');
})
,
]);
}

public function getFormActions(): array
{
return [
Action::make('save')->action(
function (): void {
$this->update();
}
),
];
}

public function update()
{
dd('update the dates here');
}
}
this is what I got, but I haven't been able to figure out how to view my page by using the URL. The id of the resource I want to test is 2. How do I find out the URL?
10 replies
FFilament
Created by Pathros on 6/10/2024 in #❓┊help
How to enable close on select belongsToMany Select?
I got this custom page Select element Wizard form:
<?php
Select::make('data.researchtopics')
->relationship('researchtopics','name')
->multiple()
->preload()
<?php
Select::make('data.researchtopics')
->relationship('researchtopics','name')
->multiple()
->preload()
in the wizard form, when you select a topic, the select list is still available and is hiding the "next" button of the Wizard, which causes confusion to the user. So, how do you enable a "close on select" feature?
2 replies