nova-flexible-content
nova-flexible-content copied to clipboard
Validation rules don't work when placing Flexible field inside DependencyContainer
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.
];
}
}