nova-flexible-content icon indicating copy to clipboard operation
nova-flexible-content copied to clipboard

Add ability to only allow X numbers of layout instances

Open adrienleloup opened this issue 7 years ago • 6 comments

It could be useful to be able to limit the amount of times a layout can be added to the flexible field.

For example, if the field is used as a replacement for the BelongsToMany field, it is necessary to limit to 1 the amount of times a layout can be added, as adding 2 of the same layout is going to cause the first one to be overriden by the second one.

Another, maybe simpler example:

We have a Flexible field to allow the user to construct their About page with predefined sections. But maybe we want to limit the Contact info section to only appear once on the page. If the user has already added a Contact info section, the option would then be either removed or greyed out from the list when adding a new layout, maybe with a helpful tooltip message explaining that they have exceeded the maximum amount this section allows.

adrienleloup avatar Feb 27 '19 13:02 adrienleloup

does anyone has figured this out ?

rmmaitrey avatar Apr 25 '19 11:04 rmmaitrey

I actually wrote a similar feature on my fork, I'll modify it to solve this issue and make a PR

m-triassi avatar Jul 04 '19 21:07 m-triassi

@m-triassi That would be super nice, thank you!

adrienleloup avatar Jul 05 '19 08:07 adrienleloup

A part of the feature request has been merged in v0.1.9 (the Flexible::limit() method).

We still need the ability to limit the number of instances of each layout type individually.

toonvandenbos avatar Aug 22 '19 14:08 toonvandenbos

Any updates on this?

KasparRosin avatar Feb 07 '20 08:02 KasparRosin

Hi @KasparRosin, this is low priority for us and falls behind a lot of the other issues, so it may be a while. PRs are welcome, though!

adrienleloup avatar Feb 07 '20 09:02 adrienleloup