Zend Framework

Zend_Form_Element_File getFileName should have an additional optional parameter to truncate the path

Details

  • Type: Improvement Improvement
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.7.0
  • Fix Version/s: 1.8.0
  • Component/s: Zend_Form
  • Labels:
    None

Description

The Zend_Form_Element_File getFileName($value = null) function should have an additional optional parameter which would be $path = null just like in the Zend_File_Transfer_Abstract class where the getFileName accepts a boolean (on the second parameter) which will truncate the full path if true is passed.

If value is empty, the adapter's getFileName is called and therefore Zend_Form_Element_File getFileName function should be behaving the same as the one in the abstract class.

The suggested correction would then be:

public function getFileName($value = null, $path = null)
{
if (empty($value)) { $value = $this->getName(); }

return $this->getTransferAdapter()->getFileName($value, $path);
}

Activity

Hide
Thomas Weidner added a comment -

And why should this be a bug ?
What you describes looks for me like a feature request and not like a bug.

Show
Thomas Weidner added a comment - And why should this be a bug ? What you describes looks for me like a feature request and not like a bug.
Hide
Thomas Weidner added a comment -

Changed type from bug to improvement.

Show
Thomas Weidner added a comment - Changed type from bug to improvement.
Hide
Thomas Weidner added a comment -

According to manual and API doc the method getValue returns ONLY the filename without path.
To get the complete path you must use getFileName().

So eighter use getValue or call basename on the returned information.

Show
Thomas Weidner added a comment - According to manual and API doc the method getValue returns ONLY the filename without path. To get the complete path you must use getFileName(). So eighter use getValue or call basename on the returned information.
Hide
Steven Rosato added a comment -

My bad about choosing the wrong type.

getValue() works well but I thought that since the getFileName() function uses the transfer adapter's getFileName() function, it should behave in a similar way.

Show
Steven Rosato added a comment - My bad about choosing the wrong type. getValue() works well but I thought that since the getFileName() function uses the transfer adapter's getFileName() function, it should behave in a similar way.
Hide
Thomas Weidner added a comment -

Behaviour improved with r13712

Show
Thomas Weidner added a comment - Behaviour improved with r13712

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: