@philipp: Unfortunately, that is not possible. $page->categories()->split()returns an array, not a collection. And you cannot use the limit() method on an array. You would have to use array_slice(), see PHP Manual.
@heyallan: As far as I know there is no validator for the blueprint. Not sure if you could use a custom validator, though.
BTW I also tried with structure field, but had similar experience: structure field can limit the number of values per entry, but not the number of entries.
What do you think about validating the string with regex?
Something like:
I don’t think that would work. The validator checks the result before the content is written to the content file. And you don’t have a single input field that you could validate.
If you mean a “specific arbitrary number”: What about three select fields that each have a width of ⅓? Then it’s clear that you can always select exactly three pages.
3 Select fields is a functional alternative.
That would give me 3 separate fields instead of 1 though.
Trying ‘checkboxes’, ‘structure’, or ‘page’ fields sounded more logical to me at first,
but very different limitations each:
Checkboxes:
Very handy UI, but can’t limit the number of values per field
Structure:
Very handy UI, but can’t limit the number of fields (duplicates)
Page:
‘Page’ field is more like a ‘search’ field, if the user doesn’t remember the name of the page she’s looking for from the top of her head it won’t be very helpful. ‘Search’ and ‘select’ are very different approaches. And if I remember correctly it only accepts 1 value per field
I really liked the ‘checkboxes’ approach, I think I’ll stick with it, I’ll hide any extra values when I catch them at the template part.