epartment / nova-dependency-container

A Laravel Nova field container allowing to depend on other fields values
MIT License
382 stars 163 forks source link

Panel is not supported #130

Closed keizah7 closed 3 years ago

keizah7 commented 4 years ago

It would be cool if package in future support Field Panels

RafaelEmery commented 3 years ago

Thanks for this issue, i was having an error due to not supporting Panels! It would be nice to have suport for Panels.

theofanisv commented 3 years ago

A workaround I am using is to get the fields contained in the Panel and set them as fields for NovaDependencyContainer and then set that NovaDependencyContainer field as child in the original Panel. On nova form this renders the titles of the Panel but not their encapsulated fields, but when you set the dependent value the panel containing the corresponding NovaDependencyContainer renders as it should and the data are passed successfully to the back end.

public function fields(Request $request)
    {
        return [
            new Panel('Panel-A', [
                NovaDependencyContainer::make([
                    // original Panel-A fields
                ])->dependsOn('category.id',$id)
            ]),
        ];
    }
ragingdave commented 3 years ago

I've been using the same sort of workaround to be honest, as dealing with panels delves way deep into nova core, as panels are first class objects so to speak there and have a ton of functionality associated with them.

Someone can for sure try and work up a PR if they would like, but the workaround is the way for the foreseeable future.