whitecube / nova-flexible-content

Flexible Content & Repeater Fields for Laravel Nova
MIT License
791 stars 235 forks source link

Panels/Tabs with Flexible #231

Open ahinkle opened 4 years ago

ahinkle commented 4 years ago

Sometimes we have many flexible fields that need to be organized appropriately.

These can be done in various ways such as

However, using them with Flexible fields throws an error:

Argument 1 passed to Whitecube\NovaFlexibleContent\Layouts\Layout::cloneField()
must be an instance of Laravel\Nova\Fields\Field, instance of Laravel\Nova\Panel given,

Replicate:

Flexible::make('Page Content', 'content')
    ->addLayout('Panel', 'panel', [
        (new Panel('Profile', [
            Text::make('Full Name'),
            Text::make('Place of Birth'),
        ]))->limit(1),
    ])
temp1029 commented 4 years ago

This also seems to be occurring when there is a Trix field that can store files (i.e. uses 'withFiles'). This occurs even when the Panel isn't used.

Inside of fields function

return [
    Trix::make('Top Ad', 'mkt_top_ad')->withFiles('public')->hideFromIndex()->alwaysShow()->nullable()->stacked(),
    Flexible::make('Badges')
    ->addLayout('', '', [
        Image::make('Badge', 'badge')->maxWidth(150)->disk('public')
    ])->button('Add Badge'),
];

Removing the 'withFiles' call no longer presents this error.