cvs: pear /HTML_QuickForm QuickForm.php
| From: | Bertrand Mansion | Date: | Wed, 05 Dec 2001 09:17:17 +0000 |
| Subject: | cvs: pear /HTML_QuickForm QuickForm.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-1467@lists.php.net to get a copy of this message | ||
mansion Wed Dec 5 04:17:17 2001 EDT
Modified files:
/pear/HTML_QuickForm QuickForm.php
Log:
Thanks to David Weingart for the bugfix :
When adding a file input in a group, form attributes (method, max filesize, enctype) were not
updated accordingly.
This fixes the problem.
Index: pear/HTML_QuickForm/QuickForm.php
diff -u pear/HTML_QuickForm/QuickForm.php:1.6 pear/HTML_QuickForm/QuickForm.php:1.7
--- pear/HTML_QuickForm/QuickForm.php:1.6 Mon Nov 26 12:00:45 2001
+++ pear/HTML_QuickForm/QuickForm.php Wed Dec 5 04:17:17 2001
@@ -17,7 +17,7 @@
// | Bertrand Mansion <bmansion@mamasam.com> |
// +----------------------------------------------------------------------+
//
-// $Id: QuickForm.php,v 1.6 2001/11/26 17:00:45 mansion Exp $
+// $Id: QuickForm.php,v 1.7 2001/12/05 09:17:17 mansion Exp $
require_once("PEAR.php");
require_once("HTML/Common.php");
@@ -450,6 +450,20 @@
*/
function addElementGroup($elements, $label="", $name=null,
$groupLayout="rows")
{
+ // Update form attributes if there is a file input in the elements array
+ foreach ($elements as $el) {
+ if ($this->_fileFlag == true) {
+ break;
+ }
+ if ($el->getType() == 'file') {
+ $this->updateAttributes(array("method"=>"POST",
"enctype"=>"multipart/form-data"));
+ $err = &$this->addElement('hidden', 'MAX_FILE_SIZE',
$this->_maxFileSize, '');
+ if (PEAR::isError($err)) {
+ return $err;
+ }
+ $this->_fileFlag = true;
+ }
+ }
$elementObject = &HTML_QuickForm::createElement('group', $name, $elements,
null, $groupLayout);
if (PEAR::isError($elementObject)) {
return $elementObject;