[Pieforms-commit] SF.net SVN: pieforms: [83] pieforms-php5/trunk/src/pieform.php
Status: Alpha
Brought to you by:
oracleshinoda
From: <ora...@us...> - 2006-12-07 05:49:42
|
Revision: 83 http://svn.sourceforge.net/pieforms/?rev=83&view=rev Author: oracleshinoda Date: 2006-12-06 21:43:30 -0800 (Wed, 06 Dec 2006) Log Message: ----------- Did one of the TODO items - use MochiKit's connect() to handle the form submission. Made sure that elements have their 'id' attribute have the form name put on the front, so more than one form can be used on the same page successfully. Modified Paths: -------------- pieforms-php5/trunk/src/pieform.php Modified: pieforms-php5/trunk/src/pieform.php =================================================================== --- pieforms-php5/trunk/src/pieform.php 2006-12-07 05:41:51 UTC (rev 82) +++ pieforms-php5/trunk/src/pieform.php 2006-12-07 05:43:30 UTC (rev 83) @@ -66,7 +66,6 @@ // // - more form element types (inc. types like autocomplete and date picker and wyswiyg) // - support processing of data before validation occurs (e.g. trim(), strtoupper()) - // - do onsubmit for ajax stuff by mochikit connect() // - Basic validation is possible as there's a callback function for checking, // but some helper functions could be written to make people's job validating // stuff much easier (form_validate_email, form_validate_date etc). @@ -328,7 +327,6 @@ $formdefaults = array( 'method' => 'get', 'action' => '', - 'onsubmit' => '', 'ajaxpost' => false, 'preajaxsubmitcallback' => '', 'postajaxsubmitcallback' => '', @@ -354,7 +352,6 @@ $this->action = $data['action']; $this->validate = $data['validate']; $this->submit = $data['submit']; - $this->onsubmit = $data['onsubmit']; $this->autofocus = $data['autofocus']; $this->language = $data['language']; @@ -683,9 +680,6 @@ if ($this->fileupload) { $result .= ' enctype="multipart/form-data"'; } - if ($this->ajaxpost) { - $result .= ' onsubmit="' . $this->name . '_submit(); return false;"'; - } $result .= ">\n"; // @todo masks attempts in pieform_render_element, including the error handling there @@ -871,7 +865,8 @@ private function submit_js() { // @todo nigel should disable all buttons on this form while the submit is happening $result = <<<EOF -function {$this->name}_submit() { + +connect($('{$this->name}'), 'onsubmit', function (e) { // eventually we should check input types for wysiwyg before doing this // Also should only save wysiwyg elements in the form, not all of them... if (typeof(tinyMCE) != 'undefined') { tinyMCE.triggerSave(); } @@ -961,8 +956,8 @@ $result .= <<<EOF }); {$this->name}_message('{$strprocessingform}', 'info'); - return false; -} + e.stop(); +}); EOF; @@ -1110,12 +1105,15 @@ * @param array $exclude Any attributes to explicitly exclude from adding * @return string The attributes for the element */ - public static function element_attributes($element, $exclude=array()) { + public function element_attributes($element, $exclude=array()) { static $attributes = array('accesskey', 'class', 'dir', 'id', 'lang', 'name', 'onclick', 'size', 'style', 'tabindex'); $elementattributes = array_diff($attributes, $exclude); $result = ''; foreach ($elementattributes as $attribute) { if (isset($element[$attribute]) && $element[$attribute] !== '') { + if ($attribute == 'id') { + $element[$attribute] = $this->name . '_' . $element[$attribute]; + } $result .= ' ' . $attribute . '="' . self::hsc($element[$attribute]) . '"'; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |