milesj/cake-uploader — Issue #37: Uploader.FileValidation unload problem
Author: paoloiulita
Created: 2012-01-31 16:08:49+00:00
State: open

Hello, i don't know if this is a specific behavior-related problem.
The setup is simple, User actsAs Uploader.FileValidation with 'file size' and 'required' set.
in User's beforeValidate i check if a new picture was selected and if not the behavior is unloaded

a bit of code

public function beforeValidate() {
$this->_photoChanges = !empty( $this->data[ 'User' ][ 'picture' ][ 'name' ] );
if( !$this->_photoChanges ) {
//photo remains the same
$this->Behaviors->unload( 'Uploader.FileValidation' );
$this->Behaviors->unload( 'Uploader.Attachment' );
$this->data[ 'User' ][ 'picture' ] = $this->data[ 'User' ][ 'currentPicture' ];
}
return true;
}

when this occurs i get a warning:

Warning (512): Could not find validation handler filesize for picture [CORE/Cake/Model/Model.php, line 2989]
Warning (512): Could not find validation handler required for picture [CORE/Cake/Model/Model.php, line 2989]

'picture' is obviously the name of the form's field

if i check attached behaviors with debug($this->Behaviors->attached()) it says that the behavior has been correctly unloaded

any ideas?