alexwenzel / nova-dependency-container

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

Field validation support when using whitecube/nova-flexible-content package. #17

Closed riptin closed 5 months ago

riptin commented 2 years ago

Hello again, I'm using this package alongside with whitecube/nova-flexible-content. When I place its Flexible field in DependencyContainer, the validation rules are ignored.

use App\Nova\Flexible\Layouts\ImagesLayout;
use App\Nova\Flexible\Layouts\VideoUrlLayout;
use Whitecube\NovaFlexibleContent\Flexible;
use Alexwenzel\DependencyContainer\HasDependencies;
use Alexwenzel\DependencyContainer\DependencyContainer;

use HasDependencies;

DependencyContainer::make([
      Flexible::make('Overview')
          ->addLayout(ImagesLayout::class)
          ->addLayout(VideoUrlLayout::class)
          ->button('Add Section'),
])->dependsOn('finished', 1)

The layout file with the rules

namespace App\Nova\Flexible\Layouts;

use Laravel\Nova\Fields\Text;
use Whitecube\NovaFlexibleContent\Layouts\Layout;

class VideoUrlLayout extends Layout
{
    public function fields()
    {
        return [
          Text::make('Video Url')->rules(['required']), // The rules work when using this layout otuside the Flexible field
        ];
    }
}

Since I don't know which package isn't supporting the other one, I opened this issue in their repository too #https://github.com/whitecube/nova-flexible-content/issues/418 .

ThaDaVos commented 2 years ago

Maybe it's related to this? https://github.com/alexwenzel/nova-dependency-container/issues/20

riptin commented 1 year ago

Thanks for the reply. I tried your commit but the rules are still ignored.

ThaDaVos commented 1 year ago

@riptin - the only thing my commit fixes atm is the issue of the ActionRequest being overridden in cases where it shouldn't, so for example, an action which doesn't use the required trait

I haven't looked in the rules issue - only said it may be related or a possible cause of the issue

lonnylot commented 1 year ago

@riptin Not sure if you're still stuck on this, but I created a patch. Please let me know if it helps.