Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dont work with multiple Levels #178

Open
jayvs6341 opened this issue Jun 29, 2021 · 3 comments
Open

Dont work with multiple Levels #178

jayvs6341 opened this issue Jun 29, 2021 · 3 comments

Comments

@jayvs6341
Copy link

jayvs6341 commented Jun 29, 2021

$res[] = Select::make('Status')->rules('required')->options([
            '1' => 'Active',
            '0' => 'Inactive',
        ])->displayUsingLabels()->hideFromIndex();

 $res[] = NovaDependencyContainer::make([
            Select::make('Select All Devices','is_all')->rules('required')
            ->options([
                '1' => 'No',
                '0' => 'Yes (Application will not be visible to any device)',
            ])->displayUsingLabels()->hideFromIndex()
        ])->dependsOn('status',0)->creationRules('required')->updateRules('required');

$res[] = NovaDependencyContainer::make([
            Multiselect::make('Blocked Device Ids', 'device_ids')
                ->options(
                    Device::pluck('hwid', 'id')
                )
               
        ])->dependsOn('is_all',1)->creationRules('required')->updateRules('required')->hideFromDetail();
@ragingdave
Copy link
Collaborator

This is going to need some more info to know what exactly isn't working here, as I can't really make any sense out of what you have here. Specifically if you can give a little background on what you are expecting vs what is happening that'd be ideal.

@jayvs6341
Copy link
Author

For instance,
There are three controls.
A->B->C
B is dependent on A and C is on B.
If I change in A value, it should update B ( That is working ). and If I change in value of B, it should reflect to C.(This is not working).

@Monomachus
Copy link

Monomachus commented Oct 19, 2021

@ragingdave what you need is to indicate the dependencies on the same level

Basically something like this

BelongsTo::make('Tenant', 'tenant', \App\Nova\Tenant::class)
  ->nullable()
  ->searchable()
  ->sortable()
  ->onlyOnForms(),

NovaDependencyContainer::make([
                BelongsTo::make('Room', 'room', \App\Nova\Room::class)
                    ->withoutTrashed()
                    ->nullable()
                    ->searchable()
                    ->withSubtitles(),

                    NovaDependencyContainer::make([
                        BelongsTo::make('Building', 'building', \App\Nova\Building::class)
                            ->withoutTrashed()
                            ->searchable(),

                        Hidden::make('Building', 'building_id')
                        ->fillUsing(function ($request, $model, $attribute, $requestAttribute) {
                            $building = $model->building;
                            $model->{$attribute} = $building['id'];
                        }),
                    ])->dependsOnEmpty('room')->onlyOnForms(),

                    NovaDependencyContainer::make([
                        Hidden::make('Building', 'building_id')
                        ->fillUsing(function ($request, $model, $attribute, $requestAttribute) {
                            $room = $model->room;
                            $model->{$attribute} = $room['building_id'];
                        }),
                    ])->dependsOnNotEmpty('room')->onlyOnForms(),
            ])->dependsOnEmpty('tenant')->onlyOnForms(),

In my example I have
Building depends on Room; Room depends on Tenant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants