Flexible Fields is a Laravel Nova package that allows you to easily create repeatable fields or blocks within a resource. Check out this demo gif to get a better idea on how it works:
Flexible Fields allow you to use all the Laravel Nova field types, and also any community-made fields. So it's flexible enough to fit any setup you desire.
Once you have it installed you can add fields to your layouts like this:
1use Whitecube\NovaFlexibleContent\Flexible; 2 3/** 4 * Get the fields displayed by the resource. 5 * 6 * @param \Illuminate\Http\Request $request 7 * @return array 8 */ 9public function fields(Request $request)10{11 return [12 // ...13 14 Flexible::make('Content')15 ->addLayout('Simple content section', 'wysiwyg', [16 Text::make('Title'),17 Markdown::make('Content')18 ])19 ->addLayout('Video section', 'video', [20 Text::make('Title'),21 Image::make('Video Thumbnail', 'thumbnail'),22 Text::make('Video ID (YouTube)', 'video'),23 Text::make('Video Caption', 'caption')24 ])25 ];26}
Which would display like this in your Nova admin:
A package like this gives you lots of power to create all sorts of dynamic content that you wouldn't otherwise be able to do easily. For more information on this package and to get started check out their official docs.
0 comments:
Post a Comment
Thanks