belongs-to-many-field-nova icon indicating copy to clipboard operation
belongs-to-many-field-nova copied to clipboard

While updating data if i change fleet type option and then selected parent category option which is not belongs to fleet type then also can save data without any error. It should not allow to save or if i change fleet type then selected parent category should remove so can select other options which is related to that fleet type.

Open Akanksha-Clarion opened this issue 3 years ago • 0 comments

What is the solution of this issue? While we change parent option it should remove the child selected options which is not related to parent. And if we save it with different parent and child options which are not belongs to each other data is saved.

I have to clear child selected data from options when we change parent options. What is the solution of this?

        BelongsTo::make('Fleet Type', 'fleetType', FleetType::class)
        ->default(function ($request) {
            if ($request->editMode == 'create') {
                return  self::MEDICAL_FLEET;
            }
        })->withMeta([
            'placeholder' => 'Select Fleet Type',
        ]),

        BelongsToManyField::make(__('Parent Category'), 'parent', Category::class)
        ->dependsOn('fleetType', 'fleet_type_id')
        ->setMultiselectProps([
            'selectLabel' => 'click for select',
            'placeholder' => 'Select Parent Category',
            'openDirection' => 'below',
            'max' => 1
        ])
        ->rules('required'),

What could be the solution that if i select other option of fleet type then selected option of parent category which is not related to that fleet type should remove. So i can select that category which is belongs to fleet type.

Akanksha-Clarion avatar Oct 26 '21 07:10 Akanksha-Clarion