public function setup()
 {
     parent::setup();
     unset($this->widgetSchema['type']);
     unset($this->widgetSchema['lft']);
     unset($this->widgetSchema['rgt']);
     unset($this->widgetSchema['level']);
     unset($this->validatorSchema['type']);
     unset($this->validatorSchema['lft']);
     unset($this->validatorSchema['rgt']);
     unset($this->validatorSchema['level']);
     $this->validatorSchema['tags'] = new sfValidatorAnd(array(new sfValidatorString(), new sfValidatorRegex(array('pattern' => '#^[^, ;]([^, ;]+[,; ] ?)*?[^, ;]+$#'))), array('required' => false));
     $directory_choices = sfFilebaseDirectoryTable::getChoices();
     $this->widgetSchema['directory'] = new sfWidgetFormTree(array('value_key' => 'id', 'choices' => $directory_choices, 'label_key' => 'filename'));
     $this->validatorSchema['directory'] = new sfValidatorTree(array('value_key' => 'id', 'label_key' => 'filename', 'choices' => $directory_choices));
     if ($this->isNew()) {
         unset($this->widgetSchema['filename']);
         unset($this->validatorSchema['filename']);
         $this->widgetSchema['hash'] = new sfWidgetFormInputSWFUpload(array('require_yui' => true, 'custom_javascripts' => array(public_path('/sfFilebasePlugin/js/fileupload.js'))));
         $this->validatorSchema['hash'] = $this->filebase->getUploadedFilesManager()->createFileUploadValidator(array('path' => $this->filebase->getPathname(), 'allow_overwrite' => true, 'required' => true));
         $this->widgetSchema['directory']->setDefault($directory_choices[0]['id']);
     } else {
         unset($this->widgetSchema['hash']);
         unset($this->validatorSchema['hash']);
         $this->validatorSchema['filename'] = new sfValidatorString();
         $p = $this->getObject()->getNode()->getParent();
         $parent_id = $p instanceof sfFilebaseDirectory ? $p->getId() : 0;
         $this->widgetSchema['directory']->setDefault($parent_id);
     }
     $this->validatorSchema->setPostValidator(new sfValidatorCallback(array('callback' => array($this, 'checkUpload'))));
 }