Hidden field works only while create and not edit
Hi, i have 2 dependant fields
when i select the BUSINESS option, a select is visible
but it works only when i create a new customer
in edit mode, doesn't works.
Solution:Jump to solution
otherwise you would have to check against the actual value
$get('customer_type') === CustomerType::BUSINESS->value
8 Replies
Do you mean, when you change the radio value in the edit page?
It appears that
$get('customer_type') === CustomerType::BUSINESS
might not be matching as expected (customer_type value is from database in the edit operation)You are casting the field in you model to the enum?
hi, this is my enum
no casts i nthe customer model
you need to cast it on the model if you are expecting it to be the enum on the model instance
Solution
otherwise you would have to check against the actual value
$get('customer_type') === CustomerType::BUSINESS->value
thanks, i will try
@Soundmit i hade the same issue.
I have cast on the model and use a "helper function" so it will work on create and edit form
sidenote : All my enums are numeric so possible the code can be optimzed to meet you needs.
Somethin like instance of enum
this solve
->visible(fn (Get $get) => $get('customer_type') === CustomerType::BUSINESS->value)
thanks