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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Adding validation


Go to End


3 Posts   1155 Views

Avatar
paul.mcilwaine

Community Member, 21 Posts

21 October 2009 at 1:03pm

Im looking at trying to add validation to a DataObject using the ImageDataObjectManager. Basically I want to verify if an Image width and size is correct before allowing a file to be uploaded. However I am stumped as in where I need to add this, I thought using the getCMSValidator method in the DataObject would work but doesn't seem to even be recognised using the ImageDataObjectManager at all.

I noticed that there is a setDetailFormValidator which is from ComplexTableField but doesn't seem to actually work with what I want to do (again didnt seem to be recognised).

Is there a way to actually do this ?

Avatar
UncleCheese

Forum Moderator, 4102 Posts

22 October 2009 at 1:32am

There's only one way to do that and it's not too easy. You need to set up a custom controller with a handleswfupload() method and do the validation there. If you need some help with it, you can contact me through my website to schedule a time for hands-on support.

Avatar
paul.mcilwaine

Community Member, 21 Posts

22 October 2009 at 11:58am

Thanks UncleCheese, I seem to have it sort of working now. However the current way I have it working is to output a a string with just a space. This causes the upload to fail (which is correct) however a minor annoyance is that i can add files to the list but cannot actually upload any files anymore unless I close the popup window and do it again.

Is there a way around this ?