PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » HTML » HTML_QuickForm » Bug #8195

MAX_FILE_SIZE in wrong place

Details

Submitted2006-07-12 16:47 UTC
Fromdobes at lnx dot cz
StatusBogus
PackageHTML_QuickForm
PHP Version5.1.4
OSwinXP
Roadmaps(Not assigned)

Comments

[2006-07-12 16:47 UTC] dobes at lnx dot cz

Description:
------------
When you use file input and set the maxfilesize, you have to render automatic created hidden MAX_FILE_SIZE input before the file field.

Automatic creation of hidden fields is not working, because you have to specified MAX_FILE_SIZE before file field and not in the end like $renderer->toHtml() do.

When use $form->setMaxFileSize() render file input like $renderer->elementToHtml('MAX_FILE_SIZE', NULL) . $renderer->elementToHtml('f', NULL)

because you don't set
$form->addElement('hidden', 'MAX_FILE_SIZE', $max_size);

and I suppose that it handle this correctly.

Test script:
---------------
$form = new HTML_QuickForm('testform', 'post');
$renderer = & new HTML_QuickForm_Renderer_QuickHtml();

$form->removeAttribute('name');
$form->removeAttribute('action');

$form->addElement('file', 'f', 'Upload file:');
$form->setMaxFileSize(32768);
$form->addElement('submit', 'send', 'Submit file');
$form->accept($renderer);

$echo = '<div class="some_html_code">choose file: '. $renderer->elementToHtml('f', NULL)).'<br>'.
$renderer->elementToHtml('send', NULL).'<div>';
return $renderer->toHtml($echo);

Expected result:
----------------
<form method="post" id="importfile" enctype="multipart/form-data">
<div class="some_html_code">choose file: <input name="f" type="file"><br>
<input name="send" value="Submit file" type="submit"><div>
<input name="MAX_FILE_SIZE" value="32768" type="hidden">
</form>

Actual result:
--------------
<form method="post" id="importfile" enctype="multipart/form-data">
<div class="some_html_code">choose file: <input name="MAX_FILE_SIZE" value="32768" type="hidden"><input name="f" type="file"><br>
<input name="send" value="Submit file" type="submit"><div>
</form>