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
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
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.
$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);
}
});