[Pieforms-commit] SF.net SVN: pieforms: [127] pieforms-php5/trunk/src/pieform.php
Status: Alpha
Brought to you by:
oracleshinoda
|
From: <ora...@us...> - 2006-12-23 05:03:38
|
Revision: 127
http://svn.sourceforge.net/pieforms/?rev=127&view=rev
Author: oracleshinoda
Date: 2006-12-22 21:03:37 -0800 (Fri, 22 Dec 2006)
Log Message:
-----------
Added a new flag, 'cancelelement', so that erraneous javascript is not added for them, and their value can still be quashed when the post data is sent. Also, allow elements to specify a function that describes how a rule applies to them, which can be very useful when the way that the rule works is 'almost' right, but you don't want to make a new rule
Modified Paths:
--------------
pieforms-php5/trunk/src/pieform.php
Modified: pieforms-php5/trunk/src/pieform.php
===================================================================
--- pieforms-php5/trunk/src/pieform.php 2006-12-23 04:35:31 UTC (rev 126)
+++ pieforms-php5/trunk/src/pieform.php 2006-12-23 05:03:37 UTC (rev 127)
@@ -677,8 +677,13 @@
log_debug($global);
foreach ($this->get_elements() as $element) {
if ($element['type'] != 'markup') {
- if (empty($element['submitelement']) ||
- !empty($element['submitelement']) && isset($global[$element['name']])) {
+ if (
+ (empty($element['submitelement']) && empty($element['cancelelement'])) ||
+ (
+ (!empty($element['submitelement']) || !empty($element['cancelelement']))
+ && isset($global[$element['name']])
+ )
+ ) {
$result[$element['name']] = $this->get_value($element);
}
}
@@ -704,12 +709,17 @@
if (isset($element['rules']) && is_array($element['rules'])) {
foreach ($element['rules'] as $rule => $data) {
if (!$this->get_error($element['name'])) {
- // Get the rule
- $function = 'pieform_rule_' . $rule;
+ // See if this element has a function that describes
+ // how this rule should apply to it
+ $function = 'pieform_element_' . $element['name'] . '_rule_' . $rule;
if (!function_exists($function)) {
- $this->include_plugin('rule', $rule);
+ // Try instead the default rule function
+ $function = 'pieform_rule_' . $rule;
if (!function_exists($function)) {
- throw new PieformException('No such form rule "' . $rule . '"');
+ $this->include_plugin('rule', $rule);
+ if (!function_exists($function)) {
+ throw new PieformException('No such form rule "' . $rule . '"');
+ }
}
}
if ($error = $function($this, $values[$element['name']], $element, $data)) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|