[Pieforms-commit] SF.net SVN: pieforms:[303] pieforms-php5/trunk/src
Status: Alpha
Brought to you by:
oracleshinoda
From: <ora...@us...> - 2009-02-27 04:27:52
|
Revision: 303 http://pieforms.svn.sourceforge.net/pieforms/?rev=303&view=rev Author: oracleshinoda Date: 2009-02-27 04:27:47 +0000 (Fri, 27 Feb 2009) Log Message: ----------- Generalise the code to detect file elements, so any custom element can declare it needs the form to POST. Thanks to Richard Mansfield Modified Paths: -------------- pieforms-php5/trunk/src/pieform/elements/file.php pieforms-php5/trunk/src/pieform.php Modified: pieforms-php5/trunk/src/pieform/elements/file.php =================================================================== --- pieforms-php5/trunk/src/pieform/elements/file.php 2009-02-23 05:17:03 UTC (rev 302) +++ pieforms-php5/trunk/src/pieform/elements/file.php 2009-02-27 04:27:47 UTC (rev 303) @@ -45,4 +45,9 @@ } }/*}}}*/ +function pieform_element_file_set_attributes($element) {/*{{{*/ + $element['needsmultipart'] = true; + return $element; +}/*}}}*/ + ?> Modified: pieforms-php5/trunk/src/pieform.php =================================================================== --- pieforms-php5/trunk/src/pieform.php 2009-02-23 05:17:03 UTC (rev 302) +++ pieforms-php5/trunk/src/pieform.php 2009-02-27 04:27:47 UTC (rev 303) @@ -322,15 +322,6 @@ $element['title'] = ''; } - // Force the form method to post if there is a file to upload - if ($element['type'] == 'file') { - $this->fileupload = true; - if ($this->data['method'] == 'get') { - $this->data['method'] = 'post'; - self::info("Your form '$this->name' had the method 'get' and also a file element - it has been converted to 'post'"); - } - } - // This function can be defined by the application using Pieforms, // and applies to all elements of this type $function = 'pieform_element_' . $element['type'] . '_configure'; @@ -350,6 +341,15 @@ $element = $function($element); } + // Force the form method to post if there is a file to upload + if (!empty($element['needsmultipart'])) { + $this->fileupload = true; + if ($this->data['method'] == 'get') { + $this->data['method'] = 'post'; + self::info("Your form '$this->name' had the method 'get' and also a file element - it has been converted to 'post'"); + } + } + // Add the autofocus flag to the element if required if (!$autofocusadded && $this->data['autofocus'] === true && empty($element['nofocus'])) { $element['autofocus'] = true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |