Skip to content

Load option of select based on other select value #1326

Answered by lee-to
benjy8001 asked this question in Q&A
Discussion options

You must be logged in to vote

Reactive

Select::make('Select one')->options([
    1 => 1,
    2 => 2
])->reactive(function (Fields $fields, int $value, Select $field, array $values): Fields {
    $fields->findByColumn('select_two')?->options($value === 1 ? [
        4 => 4,
    ] : [2 => 2]);

    return $fields;
}),

Select::make('Select two')->options([4 => 4])->reactive(),

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@benjy8001
Comment options

@lee-to
Comment options

Answer selected by benjy8001
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants