2002 Posts in 1422 Topics by 616 members
|Go to End|
29 June 2011 at 12:53am
in my data object i need validate image dimensions before uploading.
So i created custom upload validator and it works fine, but i really don't know, how can i propagate my error messages back to upload form.
I'm using ImageField in data object popup form, here is simplified code of image field definition:
$imgField = new ImageField('Image');
If i'm uploading image, that is not valid, form (upload iframe) is redirected back because:
but without error message, how can i show these messages?
19 July 2011 at 3:15am
Don't know if this will work in the iframe field but...
.. works for other custom CMS actions http://api.silverstripe.org/2.4/forms/core/FormResponse.html
28 July 2011 at 8:25pm
i dont know if this rule really works.
We added it quiet a while ago and didnt use this rule meanwhile.
But you could try it.
Download the netefxValidator module and add a rule like:
$rule_logoDimensions = new NetefxValidatorRule("Logo", "FUNCTION", array('NetefxValidatorLibrary',
array('field' => 'Image',
'minWidth' => 10,
'maxWidth' => 0,
'minHeight' => 0,
'maxHeight' => 500)), "The width of the image has to be at least 10px, the height is not allowed to be more than 500px");
Of course you could split it in 2 seperate rules
Let me know if this rule doenst work.
|Go to Top|