PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » DB_DataObject_FormBuilder » Bug #2193

filename lost on dataobject->update()

Details

Request #2193filename lost on dataobject->update()
Submitted2004-08-22 21:07 UTC
Fromluciano at praga dot org dot ar
Assignedmw21st
StatusWont fix
PackageDB_DataObject_FormBuilder
PHP Version4.3.4
OSi386 (UML)linux-2.6.7
Roadmaps(Not assigned)

Comments

[2004-08-22 21:07 UTC] luciano at praga dot org dot ar

Description:
------------
-Have a DataObject file field $do->file
-Using a QuickForm 'file' element in preDefElements.
-Then when $fbuilder->processForm() is called you have 2 behaivors:
1) On $do->insert() the file['name'] is used as field value
2) On $do->update() if you leave the upload box in blank, an '' empty value is asigned to the field, so as result you lose the do->file value

Expected result:
----------------
Preserve the do->file field value if no file is uploaded, because that means that you call an edit form to modify some other information than the file field, so why to change it?

Actual result:
--------------
On do->update() the do->file field value get lost

Suggested workarround:

if (isset($value['tmp_name'])) {
$this->debug(" (converting file array) ");
- $value = $value['name'];
+ if ($value['tmp_name'] == '') {
+ $value = $this->_do->$field;
+ } else {
+ $value = $value['name'];
+ }
}

[2004-08-28 16:06 UTC] luciano at praga dot org dot ar

But this pice of code is from formbuilder->processForm:

if (isset($value['tmp_name'])) {
$this->debug(" (converting file array) ");
$value = $value['name'];

so, you have added kind of support to file elements, and IMHO this must be either a full support or a null support. Cause if you relay on formbuilder ability to store for you the file name, you will expect that preserve the values on update just like formbuilder do whit others fields. If formbuilder does not recognize your hand added file element, is for shure that you have to handle the suitation manualy.
A small /*comment*/ somewhere in the code can help too.

Regards and many thanks for your time