Skip to content

Conversation

niekbr
Copy link

@niekbr niekbr commented Sep 1, 2021

With custom layouts, set the $limit attribute to be able to not only limit the total number of groups but also limit the groups per layout type.

Example:

Flexible::make(__('Deployment'), 'deployment')
    ->addLayout(PHP::class)
    ->addLayout(Node::class)
    ->addLayout(Database::class);

With layout example:

<?php

namespace App\Nova\Flexible\Layouts;

use Laravel\Nova\Fields\Select;
use Laravel\Nova\Fields\Boolean;
use Whitecube\NovaFlexibleContent\Layouts\Layout;

class PHP extends Layout
{
    protected $name = 'php';
    protected $limit = 1;
    public function title()
    {
        return __('PHP');
    }
    public function fields()
    {
        return [
            Select::make(__('PHP Version'), 'php_version')
                ->options([
                    '7.4' => '7.4',
                    '8.0' => '8.0',
                ])
                ->displayUsingLabels()
                ->default('8.0'),
            Boolean::make(__('Laravel'), 'laravel')
                ->default(true),
            Boolean::make(__('Laravel Horizon'), 'laravel_horizon'),
        ];
    }
}

results in:
Screenshot from 2021-09-01 17-08-43

and after reaching the PHP limit:
Screenshot from 2021-09-01 17-08-49

Copy link
Member

@toonvandenbos toonvandenbos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @niekbr,

Thanks for your PR.

To be honest, I'm working on a refactor of this package that will address a lot of issues and add some new features as well. This is one of the aspects I'm handling in the new version, but since I have no idea when I'll have time to finish nova-flexible-content v2, I'll merge this PR in the current version.

Again, thanks !

@toonvandenbos toonvandenbos merged commit 0e9113b into whitecube:master Sep 2, 2021
jordyvanderhaegen pushed a commit to esign/nova-flexible-content that referenced this pull request Dec 4, 2024
…mmand-to-create-livewireflex-components

Added support for livewire components
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants