TimOetting / kirby-builder

A site builder extension for Kirby CMS
398 stars 50 forks source link

[Feature Request] 'Max' and 'Min' Options #66

Closed luxlogica closed 2 years ago

luxlogica commented 5 years ago

Use-Case: Landing Page Sections

We want to be able to allow the client to add Landing Pages to their site. Each Landing Page is going to be structured like this:

Solution

In this common scenario, just having a max option at the builder field level is not enough: the user could easily delete the mandatory sections (hero, contact), as well as add multiple, unnecessary hero or contact sections that are not wanted.

We need to be able to specify in each fieldset how many blocks of that type should be allowed. It is also necessary to have an accompanying min option, so we can specify that some blocs are required - and once that min number is reached, then the 'delete' option for the block should be greyed out. Example:

landing_sections:
  type: builder
  label: Landing Page Sections 
  fieldsets:
    hero:
      label: Hero Banner
      # max + min to guarantee we'll always have 1
      min: 1
      max: 1
      fields: [...]
    info:
      label: Info Section
      # no min or max - can have any number
      fields: [...] 
    contact:
      label: Contact Section
      # max 1 only - optional section
      max: 1
      fields: [....]
luxlogica commented 5 years ago

Actually, even if all we had was min as well as max options at the FIELD level, that would already enable us to find a workaround: we could use multiple builder fields instead, and that would also work:

hero:
  type: builder
  label: Hero Banner
  # always need to have 1, and only 1
  min: 1
  max: 1
  filedsets:
    [...]
info:
  type: builder
  label: Info Sections
  # no restrictions, can specify as many as needed
  fieldsets:
    [...]
contact:
  type: builder
  label: Contact Section
  # one only, or none at all
  max: 1
  fieldsets:
    [...]

I’ll change the title of the issue to reflect.

TimOetting commented 2 years ago

Closing this issue because this plugin will no longer be maintained, as its main functionality can be replaced by Kirby's built-in Blocks Field and Layout Field.