# Repeater field minimum limit

**URL:** <https://discourse.getcockpit.com/t/repeater-field-minimum-limit/1392>\
**Category:** Support\
**Created:** [April 27, 2020, 6:12pm UTC](https://discourse.getcockpit.com/t/repeater-field-minimum-limit/1392 "2020-04-27T18:12:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alessandro1992ma](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@alessandro1992ma](https://discourse.getcockpit.com/u/alessandro1992ma)\
**Post date:** [April 27, 2020, 6:12pm UTC](https://discourse.getcockpit.com/t/repeater-field-minimum-limit/1392/1 "2020-04-27T18:12:47Z")

</div>

Is it possible to set a minimum of blocks for the repeater field?

Now there is Limit but this alone a maximum limit, I wish I could also set a minimum limit.

Thank you

---

<div class="post-metadata">

**Author:** ![raffaelj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/raffaelj/32/331_2.png) [@raffaelj](https://discourse.getcockpit.com/u/raffaelj)\
**Post date:** [April 30, 2020, 6:24pm UTC](https://discourse.getcockpit.com/t/repeater-field-minimum-limit/1392/2 "2020-04-30T18:24:54Z")

</div>

You can make it required, than the minimum is 1. Other than that… You could use a modified `field-repeater.tag`, but after all these suggestions in other threads to replace a field, there won’t be much left from the core anymore 😄

You could hook into the `collections.save.before` event and return an error message if your field doesn’t validate.

```php
$app->on('collections.save.before.collection_name', function($name, &$entry, $isUpdate) {
    if (array_key_exists('field_name', $entry) {
        // check if empty: do nothing
        // check if array and count
        // if > min --> do nothing
        // else $this->stop(['error' => 'not enough blocks'], 412);
    }
});

```
