And this will include other problems.

Zend_File_Transfer is not build only to work with Zend_Form.
It's the other way round. Zend_Form_Element_File was build upon Zend_File_Transfer.

The core component will support other adapters, uploading and other features.
And all changes have to make sure the base component is not broken.
All methods and function must be aware of this.

That said, add a issue and it will be fixed when it fits, else we will find another solution.
But 1.6.0 will be released anyway.
There are ALWAYS issues and things which seem to be very important.

So please be patient.

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

----- Original Message ----- From: "enportugal" <[EMAIL PROTECTED]>
To: <fw-general@lists.zend.com>
Sent: Sunday, August 31, 2008 7:55 PM
Subject: Re: [fw-general] ZF 1.6.0 sanity check packages.



Zend_Form_Element_File


I've been digging and it seams the the value receive by the isValid() method
is NULL.

So, we need to access the file name that is set by the adapter

The problem is that the adapter don't have a method t return only the value,
instead it returns the full path.

I added a small method to return only the field value

FILE: Zend_File_Transfer_Adapter_Abstract

   function getFileValue($file)
   {
        $file = (string) $file;
       if (!array_key_exists($file, $this->_files)) {
            return null;
       }

       return  $this->_files[$file]['name'];
   }

Width this function we can access the field value at validation.

So we need to add a small piece of code here

FILE: Zend_Form_Element_File
METHOD: isValid($value, $context = null)

After this line

$this->setValue($adapter->getFileName($this->getName()));


Add this

if(null === $value)
       {
           $value = $adapter->getFileValue($this->getName());
       }


Now, it works just fine, even when the filed is not set to required


Regards,

--
View this message in context: http://www.nabble.com/ZF-1.6.0-sanity-check-packages.-tp19235906p19244461.html Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to