Ver Mensaje Individual
  #1 (permalink)  
Antiguo 27/04/2012, 14:18
Avatar de squall2501
squall2501
 
Fecha de Ingreso: junio-2008
Mensajes: 63
Antigüedad: 15 años, 11 meses
Puntos: 0
Crear regla para dimensiones en YII

Hola estoy intentando hacer una regla para las dimensiones en YII ,pero me lanza un error que no el indice imagen no esta definido (siendo que si lo esta)


Código PHP:

public $minWidth;
public 
$maxWidth;


public function 
validateFoto($object,$attribute)
    {
        
        
$info=getimagesize($_FILES[$attribute]['tmp_name']);
        
        if (isset(
$this->minWidth)) {
            if (
$info[0] < $this->minWidth)
            {
                
$message=$this->minWidthError $this->minWidthError Yii::t('yii','Photo should be at least {width}px in width');
                
$this->addError($object,$attribute,$message,array('{width}'=>$this->minWidth));
            }
        }
        if (isset(
$this->maxWidth)) {
            if (
$info[0] > $this->maxWidth)
            {
                
$message=$this->maxWidthError $this->maxWidthError Yii::t('yii','Photo should be at max {width}px in width');
                
$this->addError($object,$attribute,$message,array('{width}'=>$this->maxWidth));
            }
        }
        
    }

En la function rule agrego 

array('imagen','validateFoto','minWidth' => 110,'maxWidth' => 110), 
Gracias