Friday, March 1, 2013

Re: beforeValidate can't modify my data

The results of pr($this->News->validationErrors) is:
Array  (      [Photo] => Array          (              [1] => Array                  (                  )            )    )

W dniu piątek, 1 marca 2013 18:13:04 UTC+1 użytkownik André Luis napisał:
give a pr() function, and paste the output here please, them i think we can help u

Em quarta-feira, 27 de fevereiro de 2013 20h58min12s UTC-3, kicaj escreveu:
I create form with many fields and fields for upload files (Photo.0.image, Photo.1.image).

How do I choose from my computer two files to upload and send form, then works perfectly. But sometimes I would like upload only one file (Photo.0.image) and the secend input file (Photo.1.image) leave empty. I prepare Photo::beforeValidate for this:

public function beforeValidate($options = array()) {
if(empty($this->data['Photo']['image']['tmp_name'])) {
unset($this->data['Photo']);
}
return true;
}

But my SaveAll() return false and results for pr($this->News->validationErrors) is:

Array (
[Photo] => Array (
[1] => Array ()
)
)

What going on?
Any idea?

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: