nova-multiselect-field icon indicating copy to clipboard operation
nova-multiselect-field copied to clipboard

Data display with optionsDependOn

Open visavi opened this issue 2 years ago • 0 comments

Data output problem I have 2 lists, resorts and hotels if their IDs are the same, then a list of resorts is always displayed Everything is saved correctly in the database, but the names are displayed incorrectly

Multiselect::make('type', 'type')
    ->options([
        'resort' => 'Resort',
        'hotel' => 'Hotel',
    ])
    ->singleSelect(),

Multiselect::make('values', 'values')
    ->optionsDependOn('type', [
        'resort' => [
            1 => 'Resort 1',
            2 => 'Resort 2',
            3 => 'Resort 3',
        ],
        'hotel' => [
            1 => 'Hotel 1',
            2 => 'Hotel 2',
            3 => 'Hotel 3',
        ]
    ])
    ->saveAsJSON(),

It turns out that it will work well only if the id of the resorts and hotels are different

visavi avatar Sep 01 '23 22:09 visavi