phydeaux
phydeaux
FFilament
Created by phydeaux on 11/1/2024 in #❓┊help
Repeater - deletable except for first item
Is it possible to have repeater items have the delete action except for the first entry? In this example, a job application with a repeater for employment history but at least one is required. This is a form in a standalone Livewire component and not in a Filament panel. I'm adding an empty entry to the repeater in the component's mount() method and that works fine. I'd like that one to always be present but if they accidentally add a one (2nd, 3rd, or 17th) without meaning to, there's no way to remove it and those fields fail validation as required. So can you either disable delete or hide the delete icon for that first one? Or, if that's not possible, is there a way to filter out fully empty entries before they go through validation?
6 replies
FFilament
Created by phydeaux on 10/18/2024 in #❓┊help
Change repeater field label based on other field value
I have a wizard form and there's a repeater on step 4. I'd like to change the label of one of the fields inside the repeater based on the value of a field on step 1. It works fine if it's outside the repeater but the $get('fieldname') comes back NULL if it's inside. Is there a way to pass that field value into the repeater somehow so it can be accessed and passed into the label() closure? I can provide code snippets if necessary.
4 replies
FFilament
Created by phydeaux on 8/12/2024 in #❓┊help
Live select field not found with $get
In a create form, I have a select field called base_position_id defined as
Select::make('base_position_id')
->label('Position')
->placeholder('Select a Base Position from DGP')
->options(function () {
return BasePosition::all()->sortBy('jobTitle')->pluck('jobTitle', 'id')
->filter(fn($value, $key) => Position::where('base_position_id', $key)
->get()
->isEmpty());
})
->required()
->live(),
Select::make('base_position_id')
->label('Position')
->placeholder('Select a Base Position from DGP')
->options(function () {
return BasePosition::all()->sortBy('jobTitle')->pluck('jobTitle', 'id')
->filter(fn($value, $key) => Position::where('base_position_id', $key)
->get()
->isEmpty());
})
->required()
->live(),
Right below that, I have this inside a Split and a Section:
Placeholder::make('code')
->label('Position Code:')
->inlineLabel()
->content(fn(Get $get) => $get('base_position_id') ?: '')
->disabled(),
Placeholder::make('code')
->label('Position Code:')
->inlineLabel()
->content(fn(Get $get) => $get('base_position_id') ?: '')
->disabled(),
which works perfectly. So I know base_position_id is getting set correctly and should be available. But a little farther down I have another select field that I'd like to filter based on base_position_id.
Grid::make()
->relationship('alt_manager_code')
->columns(1)
->schema([
Select::make('managerCode')
->label('Override Hiring Manager')
->placeholder('Select Position to Override Manager')
->options(function (Get $get) {
info($get('base_position_id')); // LOG TO SEE IF VALUE IS AVAILABLE
return BasePosition::all()
->sortBy('jobTitle')
->pluck('jobTitle', 'id');
}),
]),
Grid::make()
->relationship('alt_manager_code')
->columns(1)
->schema([
Select::make('managerCode')
->label('Override Hiring Manager')
->placeholder('Select Position to Override Manager')
->options(function (Get $get) {
info($get('base_position_id')); // LOG TO SEE IF VALUE IS AVAILABLE
return BasePosition::all()
->sortBy('jobTitle')
->pluck('jobTitle', 'id');
}),
]),
Obviously on first load, the logged value is empty. But when I select a base_position_id and the field refreshes, it still logs a blank value. Shouldn't I be getting the selected value at that point? I need it to add a filter to the return collection.
18 replies
FFilament
Created by phydeaux on 8/6/2024 in #❓┊help
Does configureUsing work on Filament\Panel?
I'm using a logo on my panel which works fine if I set it in the panel() method of the PanelProvider. But since i'm going to want the same on every panel, I'm trying to set them in a global Service Provider. To keep things separate, I created a new provider and added this:
public function boot(): void
{
Panel::configureUsing(function (Panel $panel) {
return $panel
->brandLogo(asset('img/hrlink-logo.svg'))
->darkModeBrandLogo(asset('img/hrlink-logo-light.svg'));
}, isImportant: TRUE
);
}
public function boot(): void
{
Panel::configureUsing(function (Panel $panel) {
return $panel
->brandLogo(asset('img/hrlink-logo.svg'))
->darkModeBrandLogo(asset('img/hrlink-logo-light.svg'));
}, isImportant: TRUE
);
}
I initially tried it without the isImportant but saw that mentioned elsewhere so I gave it a shot. No joy. I've also tried it in AppServiceProvider just to rule out any problems with the new one but same result. I also added a log line at the top of the boot() method to verify that it's getting called and it is. Multiple times. Any thoughts on why the config is not being picked up?
8 replies
FFilament
Created by phydeaux on 7/8/2024 in #❓┊help
Simple repeater data passing in as string instead of array
I'm being thrown for a loop by what I thought were pretty basic repeaters. I've got two simple repeaters in my form: functions & qualifications. They look like this in the migration:
$table->json('functions')->nullable();
$table->json('qualifications')->nullable();
$table->json('functions')->nullable();
$table->json('qualifications')->nullable();
the form fields are defined as:
Section::make()
->columnSpanFull()
->schema([
Repeater::make('functions')
->label('Job Functions')
->addActionLabel('Add job function')
->simple(
TextInput::make('function')
),
]),

Section::make()
->columnSpanFull()
->schema([
Repeater::make('qualifications')
->label('Qualifications')
->addActionLabel('Add qualification')
->simple(
TextInput::make('qualification')
),
]),
Section::make()
->columnSpanFull()
->schema([
Repeater::make('functions')
->label('Job Functions')
->addActionLabel('Add job function')
->simple(
TextInput::make('function')
),
]),

Section::make()
->columnSpanFull()
->schema([
Repeater::make('qualifications')
->label('Qualifications')
->addActionLabel('Add qualification')
->simple(
TextInput::make('qualification')
),
]),
and I have casts in the model:
protected $casts = [
'functions' => 'array',
'qualifications' => 'array',
];
protected $casts = [
'functions' => 'array',
'qualifications' => 'array',
];
When I initially add the record - or if I manually set them to NULL and then edit it - I can add items to the repeater. What gets stored in the database is
"[\"Lorem ipsum dolor sit amet.\",\"Stet clita kasd gubergren, no sea takimata sanctus est.\"]"
"[\"Lorem ipsum dolor sit amet.\",\"Stet clita kasd gubergren, no sea takimata sanctus est.\"]"
including the surrounding quotes. But if I edit a record that has any data in the field(s), I get the following error:
foreach() argument must be of type array|object, string given at /var/www/html/vendor/filament/forms/src/Components/Repeater.php:783)
foreach() argument must be of type array|object, string given at /var/www/html/vendor/filament/forms/src/Components/Repeater.php:783)
I've been up and down the Repeater docs page numerous times and I'm not seeing anything that looks out of place. Am I missing something? Any idea what I'm doing wrong? Thanks.
7 replies
FFilament
Created by phydeaux on 3/21/2024 in #❓┊help
Wizard header layout
No description
2 replies
FFilament
Created by phydeaux on 3/14/2024 in #❓┊help
How to get the value of sibling in an Infolist RepeatableEntry
I'm trying to customize the label and/or hide an field based on the value of another field in the repeater by passing in a closure. So, hide field2 if field1 == 'Foo'. What can I pass into the closure to get the value of field1?
2 replies
FFilament
Created by phydeaux on 3/12/2024 in #❓┊help
Wizard submitAction button doesn't do validation or submission
Using a wizard in a Livewire component. I can put a wire:submit on the form tag in the blade template for the component and that works as expected. But that means I have to have a separate set of validation for just the last step, right? And the form state ends up looking very different if I do $this->form->getState() in the Livewire component than it does between steps in the Form component. So I guess the question is: Is this the expected behavior or am I doing something wrong?
3 replies
FFilament
Created by phydeaux on 3/1/2024 in #❓┊help
Radio button layout based on media breakpoint?
Is it possible to have ->inline() at larger screen sizes but not on small ones? The options wrap fine when things get too small but on some mobile screens you end up with some wrapping and some not. My gut and a quick look at the code says it can't be done but it never hurts to ask.
4 replies
FFilament
Created by phydeaux on 2/29/2024 in #❓┊help
Can you override form wizard color?
I found how to change the action buttons but is there a way to change the colors of the step header elements other than specify each piece in app.css? (This is front end outside of any panel.)
5 replies
FFilament
Created by phydeaux on 2/28/2024 in #❓┊help
requiredWithoutAll() validation being ignored
I'm using a Form Builder form in a regular Livewire component. Simple validations on the fields (required, email) work fine. But I have three fields with a requiredWithoutAll rule for the other two. So field1 has
->requiredWithoutAll('field2,field3')
->requiredWithoutAll('field2,field3')
. These rules get ignored. No error messages and nothing in the logs. Just goes along and submits without any issue. I can put a secondary validation in the Livewire component itself which does catch them but it (a) makes for an ugly UX difference and (b) for some reason, custom error messages aren't working there. Any ideas why these rules aren't getting triggered?
4 replies
FFilament
Created by phydeaux on 2/22/2024 in #❓┊help
Custom EditProfile page not rendering the form
I'm building a jobs management and application site and I want to force the user to an Applicant Profile page before they can do anything else. This uses an Applicant model that's a relation to their User object. I have the form working as a regular Livewire component/view with a Filament form but I was getting some strange behavior with validation. So I'm trying to fit it into Filament's auth profile feature to see it that fixes it. First, I know the custom EditProfile class is getting used. The properties/methods that I am overriding (heading and isSimple) are being used correctly. And in the form() function, I can dd and see the Form object that's being created and returned. But I'm not getting the form rendered on the page. Just a big blank space after the heading. Any ideas why? Second, is this even a decent way to handle this? Is it assumed that EditProfile is using a User object? I currently have
->model($this->getUser()->applicant ?? Applicant::class)
->model($this->getUser()->applicant ?? Applicant::class)
since I'm not actually going to change anything about the User object. Should I feed it the User instead and use the relationship for the applicant data? I'm really hoping to avoid going back to the standalone form and wrestling with the validation issues.
1 replies
FFilament
Created by phydeaux on 2/16/2024 in #❓┊help
Multiple authentication methods?
Is it possible to use different authentication methods for front end panel users vs. admin panel users? I need to allow normal user registration and login for the general public and authenticate our internal users against our SSO provider. This is my first Filament app and I've never done both even on a plain Laravel site. Is it possible or do I have to split this into two distinct apps? On a related note, I have a basic solution for the SSO side in Laravel by changing where the Authenticate middleware points. But do I need to do anything specific to tell Filament to use that? Am I really overthinking this? Or is the whole thing as simple as duplicating that middleware and having an admin version and a normie version?
4 replies