Checklist values
Hi, I'm trying to show fields based on checklist selection, but I'm not sure how to retrieve those selected values. When using Radio it's much easier because I use:
->visible(fn (Get $get): bool => $get('question1') === 'yes')
but how to do the same using CheckList ? I know checklist returns an array but not sure how to itSolution:Jump to solution
Loop the value of the checkbox list and if the array contains one of the values return true. Probably don’t even have to loop if you use laravel’s Arr facade. Arr::exists()
2 Replies
Solution
Loop the value of the checkbox list and if the array contains one of the values return true. Probably don’t even have to loop if you use laravel’s Arr facade. Arr::exists()
thanks @awcodes I made it in this way and it's working
->visible(fn ($get) => in_array('yes', $get('questions')))