Bonjour,
voila j'ai une erreur du type :
Warning (2): Cannot unset offset in a non-array variable [CORE\Cake\Model\Model.php, line 1794]
et
Warning (2): Invalid argument supplied for foreach() [CORE\Cake\Model\Model.php, line 1798]
Lorsque je j'utilise un saveField.
Dans un modèle j'utilise une fonction afterValidate et je souhaite lancé un enregistrement.
public function afterValidate()
{
if(isset($this->data[$this->alias]['logo_file']))
{
$file = $this->data[$this->alias]['logo_file'];
$extension = strtolower(pathinfo($file['name'] , PATHINFO_EXTENSION));
if(!empty($file['tmp_name']))
{
//ON CHARGE LA NOUVELLE IMAGE
move_uploaded_file(
$file['tmp_name'],
IMAGES . 'logos' . DS . $this->id . DS . $this->id . '.' . $extension
);
//debug($this->data);
$this->saveField('logo', 'logos/' . $this->id . '/' . $this->id . '.' . $extension);
}
}
}
Si vous avez une idée de mon erreur ...