[Pieforms-commit] SF.net SVN: pieforms: [256] pieforms-php5/trunk/src/pieform.php
Status: Alpha
Brought to you by:
oracleshinoda
From: <ora...@us...> - 2007-12-31 02:01:00
|
Revision: 256 http://pieforms.svn.sourceforge.net/pieforms/?rev=256&view=rev Author: oracleshinoda Date: 2007-12-30 18:01:02 -0800 (Sun, 30 Dec 2007) Log Message: ----------- Moved the default values for the pieform data into its own method. This should help readability of the constructor. Modified Paths: -------------- pieforms-php5/trunk/src/pieform.php Modified: pieforms-php5/trunk/src/pieform.php =================================================================== --- pieforms-php5/trunk/src/pieform.php 2007-12-31 02:00:39 UTC (rev 255) +++ pieforms-php5/trunk/src/pieform.php 2007-12-31 02:01:02 UTC (rev 256) @@ -193,118 +193,8 @@ } // Assign defaults for the form - $formdefaults = array( - // The method used to submit the form, should always be 'get' or 'post' - 'method' => 'get', + $this->data = array_merge(self::get_pieform_defaults(), $formconfig, $data); - // The form target. The vast majority of the time this should be blank, - // as the functions that handle the submit should be in the same script - // as the form definition - 'action' => '', - - // The form elements - 'elements' => array(), - - // The form renderer (see the pieform/renderers directory) - 'renderer' => 'table', - - // The directory (relative to the include path) to search for templates - 'templatedir' => '', - - // Whether to ignore E_NOTICE messages in templates - 'ignoretemplatenotices' => true, - - // Whether to validate the form. Non validated forms have none of the - // validate, success or error callbacks called on them - 'validate' => true, - - // Whether to process the submission of this form. The form will still - // be validated. Handy if the code handling the submission is elsewhere - 'submit' => true, - - // The PHP callback called to validate the form. Optional - 'validatecallback' => '', - - // The PHP callback called to process the submission of the form. - // Required, unless a success function is provided for each submit - // button in the form - 'successcallback' => '', - - // The PHP callback called if there is any validation error. Optional - 'errorcallback' => '', - - // Whether this form should submit to a hidden iframe and use DOM - // manipulation to insert error messages (faster than a normal submit, - // supported in less browsers. Most modern browsers should be fine) - 'jsform' => false, - - // The javascript function called before submission of a form - // (regardless of whether the form is a jsform) - 'presubmitcallback' => '', - - // The javascript function called after submission of a form. As non-js - // forms will trigger a page load on submit, this has no effect for them. - 'postsubmitcallback' => '', - - // The javascript function called if the form submission was successful - 'jssuccesscallback' => '', - - // The javascript function called if the form submission was unsuccessful - 'jserrorcallback' => '', - - // The javascript function called if the form submission returned an - // unknown error code - 'globaljserrorcallback' => '', - - // The message to pass back as a reason for the form submission failing - // if the form is a jsform. This can be used by your application however - // you choose. - 'jserrormessage' => '', - - // Whether this form can be cancelled, regardless of the presence of - // 'cancel' buttons or form inputs mischeviously named as to behave - // like cancel buttons - 'iscancellable' => true, - - // Whether Pieforms should die after calling a submit function. Generally - // this is a good idea, as it forces the user to reply to the form - // submission. However, there are occasions where you might want to let - // it continue, so this behaviour can be turned off - 'dieaftersubmit' => true, - - // Whether to auto-focus either the first field (if the value is true, - // or the named field (if the value is a string) when the form is - // displayed. If this has any value other than false and the form has - // been submitted with an error, the first field with an error will - // be focussed. - 'autofocus' => false, - - // The directories to search for additional elements, renderers and - // rules - 'configdirs' => array(), - - // The language to use for any form strings, such as those found in - // rules. - 'language' => 'en.utf8', - - // Any overriding language strings for rules - 'rulei18n' => array(), - - // The tabindex for the form (managed automatically by Pieforms) - 'tabindex' => false, - - // Whether to add a class of the type of the element to each element - 'elementclasses' => false, - - // Whether to add * markers after each required field - 'requiredmarker' => false, - - // Whether to show the description as well as the error message - // when displaying errors - 'showdescriptiononerror' => true, - ); - $this->data = array_merge($formdefaults, $formconfig, $data); - // Set the method - only get/post allowed $this->data['method'] = strtolower($this->data['method']); if ($this->data['method'] != 'post') { @@ -1419,6 +1309,127 @@ } }/*}}}*/ + /** + * Returns the default values for pieform data. + * + * Used in the constructor when setting up the pieform. + * + * @return array + * {@internal {PHP5 doesn't support private static const arrays, so this is a method}} + */ + private static function get_pieform_defaults() {/*{{{*/ + return array( + // The method used to submit the form, should always be 'get' or 'post' + 'method' => 'get', + + // The form target. The vast majority of the time this should be blank, + // as the functions that handle the submit should be in the same script + // as the form definition + 'action' => '', + + // The form elements + 'elements' => array(), + + // The form renderer (see the pieform/renderers directory) + 'renderer' => 'table', + + // The directory (relative to the include path) to search for templates + 'templatedir' => '', + + // Whether to ignore E_NOTICE messages in templates + 'ignoretemplatenotices' => true, + + // Whether to validate the form. Non validated forms have none of the + // validate, success or error callbacks called on them + 'validate' => true, + + // Whether to process the submission of this form. The form will still + // be validated. Handy if the code handling the submission is elsewhere + 'submit' => true, + + // The PHP callback called to validate the form. Optional + 'validatecallback' => '', + + // The PHP callback called to process the submission of the form. + // Required, unless a success function is provided for each submit + // button in the form + 'successcallback' => '', + + // The PHP callback called if there is any validation error. Optional + 'errorcallback' => '', + + // Whether this form should submit to a hidden iframe and use DOM + // manipulation to insert error messages (faster than a normal submit, + // supported in less browsers. Most modern browsers should be fine) + 'jsform' => false, + + // The javascript function called before submission of a form + // (regardless of whether the form is a jsform) + 'presubmitcallback' => '', + + // The javascript function called after submission of a form. As non-js + // forms will trigger a page load on submit, this has no effect for them. + 'postsubmitcallback' => '', + + // The javascript function called if the form submission was successful + 'jssuccesscallback' => '', + + // The javascript function called if the form submission was unsuccessful + 'jserrorcallback' => '', + + // The javascript function called if the form submission returned an + // unknown error code + 'globaljserrorcallback' => '', + + // The message to pass back as a reason for the form submission failing + // if the form is a jsform. This can be used by your application however + // you choose. + 'jserrormessage' => '', + + // Whether this form can be cancelled, regardless of the presence of + // 'cancel' buttons or form inputs mischeviously named as to behave + // like cancel buttons + 'iscancellable' => true, + + // Whether Pieforms should die after calling a submit function. Generally + // this is a good idea, as it forces the user to reply to the form + // submission. However, there are occasions where you might want to let + // it continue, so this behaviour can be turned off + 'dieaftersubmit' => true, + + // Whether to auto-focus either the first field (if the value is true, + // or the named field (if the value is a string) when the form is + // displayed. If this has any value other than false and the form has + // been submitted with an error, the first field with an error will + // be focussed. + 'autofocus' => false, + + // The directories to search for additional elements, renderers and + // rules + 'configdirs' => array(), + + // The language to use for any form strings, such as those found in + // rules. + 'language' => 'en.utf8', + + // Any overriding language strings for rules + 'rulei18n' => array(), + + // The tabindex for the form (managed automatically by Pieforms) + 'tabindex' => false, + + // Whether to add a class of the type of the element to each element + 'elementclasses' => false, + + // Whether to add * markers after each required field + 'requiredmarker' => false, + + // Whether to show the description as well as the error message + // when displaying errors + 'showdescriptiononerror' => true, + ); + }/*}}}*/ + }/*}}}*/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |