Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class PhotoForm extends BasePhotoForm
- {
- public function configure()
- {
- unset($this['product_id'] ,$this['width'], $this['height']);
- $this->widgetSchema['filename'] = new sfWidgetFormInputFileEditable(array(
- 'file_src' => '/uploads/products/photos/'.$this->getObject()->filename,
- 'edit_mode' => !$this->isNew(),
- 'is_image' => true,
- 'with_delete' => true,
- ));
- $this->validatorSchema['filename'] = new sfValidatorFile(array(
- 'mime_types' => 'web_images',
- 'path' => sfConfig::get('sf_upload_dir').'/products/photos',
- 'required' => false,
- ));
- $this->validatorSchema['filename_delete'] = new sfValidatorBoolean();
- }
- protected function saveFile($field, $filename = null, sfValidatedFile $file = null)
- {
- if (null === $file)
- {
- $file = $this->getValue($field);
- }
- $filename = $this->getUniqueFilename($this->getObject()->Product->getName() . $file->getExtension($file->getOriginalExtension()));
- $savedname = parent::saveFile($field, $filename, $file);
- return $this->createThumbNail($field , $savedname);
- }
- protected function removeFile($field)
- protected function createThumbnail($field , $savedname)
- protected function deleteThumbnail($field)
- protected function generateThumbname($name)
- protected function getUniqueFilename($name)
Add Comment
Please, Sign In to add comment