Guest User

Untitled

a guest
Jul 15th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * Idioma form.
  5. *
  6. * @package form
  7. * @subpackage Idioma
  8. * @version SVN: $Id: sfDoctrineFormTemplate.php 6174 2007-11-27 06:22:40Z fabien $
  9. */
  10. class IdiomaForm extends BaseIdiomaForm
  11. {
  12. public function configure()
  13. {
  14. unset($this['created_at'], $this['updated_at']);
  15.  
  16. /* BANDEIRA */
  17. $imagem = '<img src="/image.php/idiomas/'.$this->getObject()->getImagem().'*16*11*C" />';
  18.  
  19. $this->widgetSchema['imagem'] = new sfWidgetFormInputFileEditable(array(
  20. 'file_src' => '/uploads/idiomas/'.$this->getObject()->getImagem(),
  21. 'edit_mode' => (!$this->isNew() && $this->getObject()->getImagem()),
  22. 'with_delete' => true,
  23. 'edit_mode' => (!$this->isNew() && $this->getObject()->getImagem()),
  24. 'delete_label' => "Remover",
  25. 'template' => $imagem."<br />%input%<br />%delete% %delete_label%"
  26. ), array(
  27. 'style' => "width:auto"
  28. )
  29. );
  30.  
  31. $this->validatorSchema['imagem'] = new sfValidatorFile(array(
  32. 'required' => false,
  33. 'path' => sfConfig::get('sf_upload_dir').'/idiomas',
  34. 'mime_types' => array('image/jpeg', 'image/png', 'image/gif'),
  35. ));
  36.  
  37.  
  38. $this->validatorSchema['imagem_delete'] = new sfValidatorPass();
  39. $this->widgetSchema->setLabel('imagem', 'Imagem');
  40. }
  41.  
  42. protected function doSave($con = null){
  43. $values = $this->getValues();
  44.  
  45. if (isset($values['imagem_delete'])){
  46. $this->getObject()->unlinkImage();
  47. }
  48.  
  49. return parent::doSave($con);
  50. }
  51. }
Add Comment
Please, Sign In to add comment