informatJonas
informatJonas
FFilament
Created by informatJonas on 2/10/2025 in #❓┊help
Override select.js from filament/forms
Can I somehow overwrite the select.js of filament forms without it being overwritten again after a filament update/upgrade?
8 replies
FFilament
Created by informatJonas on 2/7/2025 in #❓┊help
Multicolor TextColumn Badge
No description
4 replies
FFilament
Created by informatJonas on 1/28/2025 in #❓┊help
Multi-Tenancy with stancl/tenancy (v4-beta)
Hello everyone, I would like to build a system where I can use the ready-made functions of Filament (+ Multi-Tenancy) incl. stancl/tenancy (v4-beta). However, as a tenant initialization, I prefer to do this by cookie (internal reasons). Installing both in one project is not a problem, but Filament automatically redirects to {Panel-URL}/{tenant-ID} after login. Do you think this can be rewritten without much effort? In general, do you think it is a good idea to rewrite the logic of Filament to cookie initialization? Thank you in advance.
2 replies
FFilament
Created by informatJonas on 5/26/2024 in #❓┊help
Dynamic select options from external api
Hello everyone, I am currently trying to fill a select field in Filament with cities after I have entered the zip code. However, it doesn't really work. Can anyone tell me how to do this correctly? I'm sure it's far too complicated at the moment. My first solution:
TextInput::make('postal_code')
->label('Postleitzahl')
->required()
->afterStateUpdated(function (Get $get, ?string $state, Set $set) use ($serviceInstance) {
if (strlen($state) === 5 && $get('country') === 'DE') {
self::$cities = $serviceInstance->loadCities($state);

if (isset(self::$cities['message'])) {
Notification::make()
->title(self::$cities['message'])
->danger()
->send();
}

if (count(self::$cities) === 1) {
$set('city', self::$cities[0]);
}
}

if ($state === null) {
$set('city', '');
}
})
->live(),
Select::make('city')
->label('Stadt/Ort')
->options(self::$cities)
->live()
->searchable()
->required(),
TextInput::make('postal_code')
->label('Postleitzahl')
->required()
->afterStateUpdated(function (Get $get, ?string $state, Set $set) use ($serviceInstance) {
if (strlen($state) === 5 && $get('country') === 'DE') {
self::$cities = $serviceInstance->loadCities($state);

if (isset(self::$cities['message'])) {
Notification::make()
->title(self::$cities['message'])
->danger()
->send();
}

if (count(self::$cities) === 1) {
$set('city', self::$cities[0]);
}
}

if ($state === null) {
$set('city', '');
}
})
->live(),
Select::make('city')
->label('Stadt/Ort')
->options(self::$cities)
->live()
->searchable()
->required(),
My current solution:
TextInput::make('postal_code')
->label('Postleitzahl')
->required()
->afterStateUpdated(function (?string $state, Set $set) {
if ($state === null) {
$set('city', '');
}
})
->reactive()
->live(),
Select::make('city')
->label('Stadt/Ort')
->options(function (Get $get) {
if ($get('postal_code') !== null && strlen($get('postal_code') === 5)) {
return GeoLocationHelper::getInstance()->loadCities($get('postal_code'));
}

return [];
})
->reactive()
->required(),
TextInput::make('postal_code')
->label('Postleitzahl')
->required()
->afterStateUpdated(function (?string $state, Set $set) {
if ($state === null) {
$set('city', '');
}
})
->reactive()
->live(),
Select::make('city')
->label('Stadt/Ort')
->options(function (Get $get) {
if ($get('postal_code') !== null && strlen($get('postal_code') === 5)) {
return GeoLocationHelper::getInstance()->loadCities($get('postal_code'));
}

return [];
})
->reactive()
->required(),
2 replies