nova-flexible-content icon indicating copy to clipboard operation
nova-flexible-content copied to clipboard

Validation rules don't work when placing Flexible field inside DependencyContainer

Open riptin opened this issue 1 year ago • 0 comments

Hello. So I'm using Flexible field with the Alexwenzel\DependencyContainer. The problem is, when I add a layout, the field rules (eg: rules(['required'])) inside the layout are ignored.

The resource:

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 VideoUrlLayout layout:

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']), // If I leave it empty, it doesn't throw any errors.
        ];
    }
}

riptin avatar Nov 24 '22 09:11 riptin