Cow
Cow
FFilament
Created by Cow on 2/10/2024 in #❓┊help
Automatically submit form when Select field changes
I have a very simple Filament form, consisting of a single Select element, which is meant to be a way to switch customers (i.e. tenants) in a multi-tenant application. When the user selects a different value in the select element, I'd like to submit the form (or otherwise perform a full page load of a specific route). The controller action would set the new value for the current customer, and then redirect to the homepage. This feels like really simple, common task, but I'm not finding any way to do it. What am I missing? Here's the relevant functions in my component:
public function mount(): void
{
$this->form->fill(['customer_code' => Auth::user()->customer->code]);
}


public function form(Form $form): Form
{
return $form
->schema(
[
Select::make('customer_code')
->hiddenLabel()
->required()
->markAsRequired(false)
->selectablePlaceholder(false)
->searchable()
->placeholder('Select')
->searchPrompt('Search')
->live()
->options(
[
'Active' => Customer::withoutTrashed()->pluck('code')->toArray(),
'Inactive' => Customer::onlyTrashed()->pluck('code')->toArray(),
]
),
]
)
;
}
public function mount(): void
{
$this->form->fill(['customer_code' => Auth::user()->customer->code]);
}


public function form(Form $form): Form
{
return $form
->schema(
[
Select::make('customer_code')
->hiddenLabel()
->required()
->markAsRequired(false)
->selectablePlaceholder(false)
->searchable()
->placeholder('Select')
->searchPrompt('Search')
->live()
->options(
[
'Active' => Customer::withoutTrashed()->pluck('code')->toArray(),
'Inactive' => Customer::onlyTrashed()->pluck('code')->toArray(),
]
),
]
)
;
}
4 replies
FFilament
Created by Cow on 11/27/2023 in #❓┊help
`FilamentColor::register()` having no effect (icons are same color as text)
Hi guys. I'm trying to implement some Filament data tables in my Jetstream project. I followed the setup instructions for the Table Builder, including running php artisan filament:install --tables, and the various other steps for configuring Tailwind, PostCSS, etc. I've set up a data table with a few TextColumns and a boolean IconColumn. The table is loading the correct data, but the icons in the IconColumn are appearing as white, just like the rest of my text. I found a section in the docs regarding registering your desired colors with FilamentColor::register() in a service provider's boot() function. I've added the following to my AppServiceProvider::boot():
public function boot(): void
{
// Configure colors for Filament
FilamentColor::register([
'danger' => Color::Red,
'gray' => Color::Zinc,
'info' => Color::Blue,
'primary' => Color::Indigo,
'success' => Color::Green,
'warning' => Color::Amber,
]);
}
public function boot(): void
{
// Configure colors for Filament
FilamentColor::register([
'danger' => Color::Red,
'gray' => Color::Zinc,
'info' => Color::Blue,
'primary' => Color::Indigo,
'success' => Color::Green,
'warning' => Color::Amber,
]);
}
However, this has no effect, and the icons are still being rendered as white, like the rest of my text. I tried creating a middleware and moving it there, but it still had no effect. I've tried restarting the npm run dev command that is running, and also separately running npm run build. I also tried each of the suggested troubleshooting steps in this discord (clearing browser cache, etc). In case it's relevant, I had initially experimented with adding a full panel to my project using the php artisan filament:install --panels command from the docs, but I have since decided to just use the components separately, so I disabled the panel by commenting out the App\Providers\Filament\AppPanelProvider::class line in my providers array in app.php. I mention this in case there's some lingering effect of creating and then disabling that panel that I'm unaware of. Any ideas where else I can look? Thanks!
8 replies