http://www.symfony-project.org/forum/index.php/m/36830/
> I'm trying to validate a file (without yaml configuration file) in my > backend app. > > My validator is executed but I can't see any error message when it fails !
Have a look here : http://www.symfony-project.org/book/1_0/10-Forms#Validators
I think you should try something like this : You are missing the
$this->getRequest( )->setError( 'yourfield', $error );
$file = $this->getRequest()->getFile('user[picture]');
if ($file)
{
// The name field must be a text entry between 2 and 100 characters
$myValidator = new sfFileValidator();
$myValidator->initialize($this->getContext(), array(
'mime_types' => array('image/jpeg', 'image/pjpeg'),
'mime_types_error' => 'Only PNG and JPEG images are allowed',
'max_size' => 512000,
'max_size_error' => 'Max size is 512Kb'
));
if (!$myValidator->execute(&$file, &$error))
{
$this->getRequest( )->setError( 'yourfield', $error );
return false;
}
}