PEAR is archived and read-only

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

Home » HTML » HTML_QuickForm » Bug #1551

changing type of an element (HTML_QuickForm_input)

Details

Submitted2004-06-03 13:19 UTC
Fromsylvain at com-ocean dot com
StatusWont fix
PackageHTML_QuickForm
PHP Version4.3.6
OSWinXP
Roadmaps(Not assigned)

Comments

[2004-06-03 13:19 UTC] sylvain at com-ocean dot com

Description:
------------
Error while changing the type of an input element (HTML_QuickForm_input) by using the HTML_QuickForm_input::setType() method

While changing a text element into a file element, the "HTML_QuickForm_file" methods couldn't be used : "Fatal error: Call to undefined function: isuploadedfile()"

The type of the element has been changed : I have a file input field in my HTML generation of the form.

(I do this because I use DB_DataObject_FormBuilder which create a text element instead of a file element for a field of my DB)

Reproduce code:
---------------
$form->addElement('text', 'FICHIER', 'Fichier :');
//1st parameters : with 'file' instead of 'text' and without 2 next lines, it work, uploaded file is moved

$file= & $form->getElement('FICHIER');
$file->setType('file');
// changing the type from text to file work : HTML Form is good : I have a file input field.
// [...]

if ($form->validate())
{
$file= & $form->getElement('FICHIER');
echo 'class name : '.get_class($file);
if ($file->isUploadedFile())
{
//[...]
}
//BUG : this method doesn't exist...
}

Expected result:
----------------
uploaded file has to be moved.

Actual result:
--------------
class name : html_quickform_text
"Fatal error: Call to undefined function: isuploadedfile()"

1st line :
The type of the element file after changing the type has been done but the type of the HTML_QuickForm_input is not the good one.
2nd line : result : the method of html_quickform_file doesn't exist...

[2004-06-03 17:43 UTC] bmansion at mamasam dot com

Let's keep that in mind for a PHP5 version ;)