Pass state value inside the createOptionForm

I have a select Component, which has a createOptionForm, I want to pass the value of neighbouring component inside the createOptionForm so I can apply some rules on it
Select::make('a_id')
Select::make('b_id')
.
.
.
->createOptionForm([
Select::('c_id')
->rules() // need the value of a_id here
])
Select::make('a_id')
Select::make('b_id')
.
.
.
->createOptionForm([
Select::('c_id')
->rules() // need the value of a_id here
])
1 Reply
Ibraheem
IbraheemOP4w ago
Resolved it by
Select::make('a_id')
Select::make('b_id')
.
.
.
->createOptionForm(fn($get) => [
Select::('c_id')
->rules(fn() => function(...) use ($get) {
dd($get('a_id')); //voila
})
])
Select::make('a_id')
Select::make('b_id')
.
.
.
->createOptionForm(fn($get) => [
Select::('c_id')
->rules(fn() => function(...) use ($get) {
dd($get('a_id')); //voila
})
])

Did you find this page helpful?