$limit = 4; // We want to limit this gridfield to 4 objects
$targetFragment = 'before' // Set gridfield target fragment value
$showLimitReachedMessage = true // We want to show the user a note when the limit is reached
$gridConfig->addComponent(
new GridFieldLimiter($limit, $targetFragment, $showLimitReachedMessage)
);
$gridConfig->addComponent(
new GridFieldAddNewButton('limiter-before-left')
);