Campos en el Formulario
Versión 1 (Guillermo Zdanowicz, 15/03/2012 18:40)
| 1 | 1 | Guillermo Zdanowicz | h1. Campos en el Formulario |
|---|---|---|---|
| 2 | 1 | Guillermo Zdanowicz | |
| 3 | 1 | Guillermo Zdanowicz | <pre> |
| 4 | 1 | Guillermo Zdanowicz | $this->widgetSchema['image_1'] = new sfWidgetFormInputFileEditable(array( |
| 5 | 1 | Guillermo Zdanowicz | 'file_src' => '/'.basename(sfConfig::get('sf_upload_dir')).'/products/normal_'.$this->getObject()->getImage_1(), |
| 6 | 1 | Guillermo Zdanowicz | 'is_image' => true, |
| 7 | 1 | Guillermo Zdanowicz | 'edit_mode' => strlen($this->getObject()->getImage_1()) > 0, |
| 8 | 1 | Guillermo Zdanowicz | 'delete_label' => 'remover el archivo actual', |
| 9 | 1 | Guillermo Zdanowicz | 'template' => '<div>%file%<br />%input%</div>' |
| 10 | 1 | Guillermo Zdanowicz | )); |
| 11 | 1 | Guillermo Zdanowicz | ... |
| 12 | 1 | Guillermo Zdanowicz | |
| 13 | 1 | Guillermo Zdanowicz | /* Validators */ |
| 14 | 1 | Guillermo Zdanowicz | $this->validatorSchema['image_1'] = new sfValidatorFileImage(array( |
| 15 | 1 | Guillermo Zdanowicz | 'required' => (! $this->getObject()->getImage_1()), |
| 16 | 1 | Guillermo Zdanowicz | 'max_size' => '5252880', |
| 17 | 1 | Guillermo Zdanowicz | 'path' => sfConfig::get('sf_upload_dir').'/products/original', |
| 18 | 1 | Guillermo Zdanowicz | 'mime_types' => 'web_images', |
| 19 | 1 | Guillermo Zdanowicz | 'min_width' => 470, |
| 20 | 1 | Guillermo Zdanowicz | 'max_width' => 99999, |
| 21 | 1 | Guillermo Zdanowicz | 'min_height' => 306, |
| 22 | 1 | Guillermo Zdanowicz | 'max_height' => 99999, |
| 23 | 1 | Guillermo Zdanowicz | 'validated_file_class' => 'sfResizedFile', // This class creates the thumbnails |
| 24 | 1 | Guillermo Zdanowicz | ), array( |
| 25 | 1 | Guillermo Zdanowicz | 'required' => 'Tenés que seleccionar una imagen principal.', |
| 26 | 1 | Guillermo Zdanowicz | 'max_size' => 'El tamaño máximo es 5 MB', |
| 27 | 1 | Guillermo Zdanowicz | //'mime_types' => 'Sólo se permiten imágenes para web (jpg, png, gif)', |
| 28 | 1 | Guillermo Zdanowicz | 'invalid_image' => '%value% no es un archivo de imagen.', |
| 29 | 1 | Guillermo Zdanowicz | 'min_width' => 'El ancho de "%value%" es muy chico (mínimo %min_width% pixels).', |
| 30 | 1 | Guillermo Zdanowicz | 'min_height' => 'El alto de "%value%" es muy chico (mínimo %min_height% pixels).', |
| 31 | 1 | Guillermo Zdanowicz | )); |
| 32 | 1 | Guillermo Zdanowicz | $this->validatorSchema['image_1_delete'] = new sfValidatorPass(); |
| 33 | 1 | Guillermo Zdanowicz | ... |
| 34 | 1 | Guillermo Zdanowicz | } |
| 35 | 1 | Guillermo Zdanowicz | |
| 36 | 1 | Guillermo Zdanowicz | </pre> |