F
Filament10mo ago
Patrick

Can't dynamicly show or hide fields in a repeater

I have a form with a select:
Select::make('course')
->label('Cursus/opleiding')
->reactive()
->options(Course::all()->pluck('name', 'id')->toArray())
->required()
Select::make('course')
->label('Cursus/opleiding')
->reactive()
->options(Course::all()->pluck('name', 'id')->toArray())
->required()
Further in the form, i have a Repeater
Repeater::make('schedule')
->label('Planning')
->reactive()
->columns(2)
->schema([
// other fields..
Select::make('course_id')
->label('Cursus')
->reactive()
->options(Course::where('is_bundle', false)->pluck('name', 'id')->toArray())
->visible(function($get){
if($get('course')){
return Course::find($get('course'))->is_bundle;
}

return false;
})->required(),
])
Repeater::make('schedule')
->label('Planning')
->reactive()
->columns(2)
->schema([
// other fields..
Select::make('course_id')
->label('Cursus')
->reactive()
->options(Course::where('is_bundle', false)->pluck('name', 'id')->toArray())
->visible(function($get){
if($get('course')){
return Course::find($get('course'))->is_bundle;
}

return false;
})->required(),
])
Now when i select a course that is a bundle, the course field should be visible, but nothing shows up. When i change the Repeater to a Grid it works just fine, but i need to be able to add multiple entries.
Solution:
Shouldn't it be $get('../../course')?
Jump to solution
4 Replies
Patrick
PatrickOP10mo ago
i can solve it by having 2 repeaters, but that would duplicate my code
Solution
LeandroFerreira
LeandroFerreira10mo ago
Shouldn't it be $get('../../course')?
Patrick
PatrickOP10mo ago
let me try that that works thank you
Patrick
PatrickOP10mo ago
is this also in the docs somewhere?
Want results from more Discord servers?
Add your server