Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Limit amount of DataObjects


Go to End


3 Posts   680 Views

Avatar
kinglozzer

Community Member, 187 Posts

20 October 2012 at 12:23am

Hi all,

I have a gallery page with an image class that extends DataObject. I want to allow CMS users to add up to 10 images, using the gridfield. How can I impose this limit?

I guess I could use onBeforeWrite to check the amount that already exist, but surely there's a better way (besides, I'm not confident that would work with the GridFieldBulkEditingTools I'm using).

Thanks

Avatar
kinglozzer

Community Member, 187 Posts

23 October 2012 at 3:27am

Anyone?

Avatar
martimiz

Forum Moderator, 1391 Posts

23 October 2012 at 11:17pm

Possibly you could try to check the amount of objects for the given page in the objects canCreate() function and return false if the limit has been reached...