[Pieforms-commit] SF.net SVN: pieforms: [102] pieforms-php5/trunk/src/pieform.php
Status: Alpha
Brought to you by:
oracleshinoda
From: <ora...@us...> - 2006-12-18 00:41:31
|
Revision: 102 http://svn.sourceforge.net/pieforms/?rev=102&view=rev Author: oracleshinoda Date: 2006-12-17 16:41:26 -0800 (Sun, 17 Dec 2006) Log Message: ----------- Allowed the form tag to be retrieved separately from the rest of the form, which allows more flexibility in how the form is built. Hopefully fix up the passing of the submit value for ajax calls now as well Modified Paths: -------------- pieforms-php5/trunk/src/pieform.php Modified: pieforms-php5/trunk/src/pieform.php =================================================================== --- pieforms-php5/trunk/src/pieform.php 2006-12-17 23:27:39 UTC (rev 101) +++ pieforms-php5/trunk/src/pieform.php 2006-12-18 00:41:26 UTC (rev 102) @@ -679,6 +679,24 @@ } /** + * Returns the HTML for the <form...> tag + * + * @return string + */ + public function get_form_tag() { + $result = '<form'; + foreach (array('name', 'method', 'action') as $attribute) { + $result .= ' ' . $attribute . '="' . $this->{$attribute} . '"'; + } + $result .= ' id="' . $this->name . '"'; + if ($this->fileupload) { + $result .= ' enctype="multipart/form-data"'; + } + $result .= '>'; + return $result; + } + + /** * Returns whether the form has been submitted * * @return bool @@ -695,20 +713,15 @@ * the other hand, this means you must be careful about escaping the URL, * especially if it has data from an external source in it. * + * @param boolean Whether to include the <form...></form> tags in the output * @return string The form as HTML */ - public function build() { - $result = '<form'; - foreach (array('name', 'method', 'action') as $attribute) { - $result .= ' ' . $attribute . '="' . $this->{$attribute} . '"'; + public function build($outputformtags=true) { + $result = ''; + if ($outputformtags) { + $result = $this->get_form_tag() . "\n"; } - $result .= ' id="' . $this->name . '"'; - if ($this->fileupload) { - $result .= ' enctype="multipart/form-data"'; - } - $result .= ">\n"; - // @todo masks attempts in pieform_render_element, including the error handling there $this->include_plugin('renderer', $this->renderer); // Form header @@ -743,7 +756,9 @@ 'value' => '' ); $result .= pieform_render_hidden($element, $this); - $result .= "</form>\n"; + if ($outputformtags) { + $result .= "</form>\n"; + } if ($this->ajaxpost) { $result .= '<script language="javascript" type="text/javascript">'; @@ -768,6 +783,9 @@ return $function($element, $this); } $global = ($this->method == 'get') ? $_GET : $_POST; + if (!empty($element['ajaxmessages']) && isset($global[$element['name']])) { + return $element['value']; + } if (isset($element['value'])) { return $element['value']; } @@ -934,7 +952,7 @@ } // Add only the submit button that was clicked - $result .= " data['{$this->name}_' + {$this->name}_btn] = document.forms['$this->name'].elements['{$this->name}_' + {$this->name}_btn].value;\n"; + $result .= " data[{$this->name}_btn] = document.forms['$this->name'].elements['{$this->name}_' + {$this->name}_btn].value;\n"; // Add the hidden element for detecting form submission $result .= " data['pieform_{$this->name}'] = '';\n"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |