Filter with value having dash '-' is not properly working

I have a SelectFilter that uses a range format, e.g. Academic Year: 2025 - 2026, 2026 - 2027. When selecting a filter, the url parameter is like this ?tableFilters[academic_year_applying_for][value]=2025+–+2026 . So, it can't fetch query because of that +-+
2 Replies
toeknee
toeknee3mo ago
what if you encode the dash?
vahnmarty
vahnmartyOP3mo ago
Thanks, this one worked.
Tables\Filters\SelectFilter::make('academic_year_applying_for__c')
->label('Academic Year')
->options(function(){
$array = ['2024 - 2025', '2025 - 2026'];
$options = [];

foreach($array as $years){
$encoded_string = htmlentities($years, ENT_QUOTES, 'UTF-8');
$options[$encoded_string] = $encoded_string;
}

return $options;

})
Tables\Filters\SelectFilter::make('academic_year_applying_for__c')
->label('Academic Year')
->options(function(){
$array = ['2024 - 2025', '2025 - 2026'];
$options = [];

foreach($array as $years){
$encoded_string = htmlentities($years, ENT_QUOTES, 'UTF-8');
$options[$encoded_string] = $encoded_string;
}

return $options;

})
Want results from more Discord servers?
Add your server