Repeater Fields and Flexible Content for Nova

Repeater Fields and Flexible Content for Nova

Flexible Content is a Laravel Nova package offered by Whitecube, allowing you to group several Nova Field Types into a single “Flexible Field“.

The operation is simple: like a “Field Panel“, the package will propose to group several fields in a “Layout” block:

public function fields(Request $request) {
    return [
            ->addLayout('Simple content section', 'wysiwyg', [
            ->addLayout('Video section', 'video', [
                Image::make('Video Thumbnail', 'thumbnail'),
                Text::make('Video ID (YouTube)', 'video'),
                Text::make('Video Caption', 'caption')

Also, the package offers the possibility to change the text of the “Add layout” button via a button() method

Flexible::make('Content')->button('Add something amazing!');

By implementing the HasFlexible trait on your models, you can then call the flexible($attribute) method, which will automatically transform the attribute value (stored in JSON by default) into a Whitecube\NovaFlexibleContent\Layouts\Collection collection.
This method then allows you to use this Flexible Content in your controllers or views.

use Illuminate\Database\Eloquent\Model;
use Whitecube\NovaFlexibleContent\Concerns\HasFlexible;

class MyCustomModel extends Model {
    use HasFlexible;

     * @return Whitecube\NovaFlexibleContent\Layouts\Collection
    public function getFlexibleContentAttribute() {
        return $this->flexible('flexible-content');

To go further, the developers propose us to use these features with another package of their creation: Nova Page. This allows you to edit static pages such as an “About Us” page without having to declare each template individually.

For installation instructions, or to learn more about this package, we invite you to visit the Github page of the whitecube/nova-flexible-content project.

Filed in: News / Nova


Join 31,000+ others and never miss out on new tips, tutorials, and more.

Laravel News Partners

Laravel Jobs

Senior Full Stack PHP Developer (Laravel)
Senior Laravel Developer
Senior Full-Stack Engineer
Developers for B2B eCommerce SaaS, AWS serverless, Laravel, Vue, Python
Remote, full time EU only
ES Tech Group
Senior PHP Developer (Laravel)
The Interaction Design Foundation