Hidden attribute not working as expected for Sections in Filament Form
Hello, I'm currently using the Filament package for a project and I've encountered an issue. I am trying to hide a Forms\Components\Section based on the value of a Forms\Components\Select input field using the hidden method. It appears that the hidden method works correctly when used with Forms\Components\DatePicker, but it does not behave as expected when applied to Forms\Components\Section. Is this a known issue, or am I perhaps using it incorrectly? Here is a snippet of the code I'm working with:
In this case, the Contract section should be hidden unless the employee_type_id is 3, but it seems to always be hidden, regardless of the employee_type_id value. Any assistance would be greatly appreciated. Thank you.
11 Replies
What does your select field look like? Also, try
!= 3
. I believe values returned as strings not ints. I tried != 3 it's not working
I tested your code and it's works fine
I switched the relation with values
try
to find out what is the actual value
I believe the problem is your select is inside another relationship. Try
return $get('employment.employee_type_id') != 3;
Also, might want to use ->visible()
instead so you're not dealing with a double negativeYes this one working fine
Thank you for your support
And if it was the other way around? I am inside the relation and I want the value of a field outside of that relation
I think you’d just use $get with the field name. Is that not working? When you’re inside a repeater you have to use the
../
syntax to get back to the parent, but in relationships I believe it’s just the normal field name.I tried like this but it doesn't work, I thought there was a reverse way
Yeah the reverse way
../
is for repeaters.
I’ll have to look at this later on my computer. Discord is horrible at formatting code on mobilethanks, this worked!!!
don't worry, thanks for helping me
Oh. Ok! Cool!