Jump to:

5450 Posts in 1672 Topics by 1197 members

Customising the CMS

SilverStripe Forums » Customising the CMS » 2.4x ImageField Validators. How to display error messages?

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

Page: 1
Go to End
Author Topic: 172 Views
  • Double-A-Ron
    Avatar
    Community Member
    599 Posts

    2.4x ImageField Validators. How to display error messages? Link to this post

    I have this code inside function getCMSFields() for a page type to restrict image uploads to 1MB:

    $image_validator = new Upload_Validator();
    $image_validator->setAllowedMaxFileSize(1048576);
    $photo1 = new ImageField('Photo1');
    $photo1->setValidator($image_validator);
    ...
    $fields->addFieldToTab( 'Root.Content.Images', $photo1 );

    Seems to work just fine. The thing is when it fails, the CMS displays no explanation to the user. There also doesn't appear to be any action in Firebug.

    Anyone know how to display a message to the user along the lines of "The file you tried to upload is too big"?

    172 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.