2009年3月29日星期日

Re: [fw-mvc] form->getValues and file upload

>> Yes, you misunderstood completly.
>>
>> When you want to "GET" the content of a file element you will of course
>> get
>> the file itself which means that it's being uploaded.
>>
>> When you want to validate a element you should call isValid() and not
>> getValues().
>
> Yes Thomas I agree with you ...
> infact I use
> if($this->getRequest()->isPost()){
> if ($form->isValid($this->_request->getPost())) {
>
> and in this case no $form->getValues() is called
> but I suppose he wants a workaround for $form->getValues()
> preventing that the receive() method being called but I didnt understand
> why ...

I still don't get the idea behind the creation of 2 not identical file
transfer objects.

As I said before... file elements don't have a value. The value of a file
element
is it's file and we emulate this by the file receivement when the user
requests the
file itself.

>
>> When you have to change the content you should apply file-filters... they
>> were build just for this usecase.
>> Only when the files are VALID you should call receive() or getValues().
>
> yes but take a look to his code ...
>> $id = $application->saveEntry($form->getValues());
>> // use new id to process and save attached file...
>> $upload = new Zend_File_Transfer();
>
> that's the problem .. the file it's just processed during the getValues()
> call
>
> Ed I think it's better if you start to consider this appoach
> if($this->getRequest()->isPost()){
> if ($form->isValid($this->_request->getPost())) {
> $id = $application->saveEntry($this->_request->getPost());
> $upload = new Zend_File_Transfer();

And this call - $upload = new Zend_File_Transfer(); - will raise an
exception.
Why not use the file element directly when he already has a $form ?
You should only use a self created file transfer object when you don't use
Zend's file elements.

>
> bye
>
> --
> ________________________________________________________________________________
>
> Simone Cosci - Planet S.r.l. Sistemi informatici
> Via Giorgio Ambrosoli, 39 - 50018, Scandicci, Firenze, Italy
> WEB: http://www.planetweb.it - http://www.ticka.it
> E-Mail s.cosci@nextidea.it
> Tel. +39 055 7350271 - Fax. +39 055 7351109
> ________________________________________________________________________________

Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com

没有评论: