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
Patrick1989
Patrick19894mo ago
i can solve it by having 2 repeaters, but that would duplicate my code
Solution
LeandroFerreira
LeandroFerreira4mo ago
Shouldn't it be $get('../../course')?
Patrick1989
Patrick19894mo ago
let me try that that works thank you
Patrick1989
Patrick19894mo ago
is this also in the docs somewhere?
Want results from more Discord servers?
Add your server
More Posts