[Pieforms-commit] SF.net SVN: pieforms: [75] pieforms-php5/trunk/src/pieform/rules/required. php
Status: Alpha
Brought to you by:
oracleshinoda
|
From: <ora...@us...> - 2006-12-06 09:21:07
|
Revision: 75
http://svn.sourceforge.net/pieforms/?rev=75&view=rev
Author: oracleshinoda
Date: 2006-12-06 01:21:00 -0800 (Wed, 06 Dec 2006)
Log Message:
-----------
Honour 'required' => false correctly (Alastair Pharo)
Modified Paths:
--------------
pieforms-php5/trunk/src/pieform/rules/required.php
Modified: pieforms-php5/trunk/src/pieform/rules/required.php
===================================================================
--- pieforms-php5/trunk/src/pieform/rules/required.php 2006-12-01 01:04:30 UTC (rev 74)
+++ pieforms-php5/trunk/src/pieform/rules/required.php 2006-12-06 09:21:00 UTC (rev 75)
@@ -27,23 +27,26 @@
/**
* Checks whether the field has been specified.
*
- * @param Pieform $form The form the rule is being applied to
- * @param string $field The field to check
- * @param array $element The element to check
+ * @param Pieform $form The form the rule is being applied to
+ * @param string $field The field to check
+ * @param array $element The element to check
+ * @param string $check Whether to check the element
* @return string The error message, if the value is invalid.
*/
-function pieform_rule_required(Pieform $form, $value, $element) {
- $function = 'form_is_empty_' . $element['type'];
- if (function_exists($function)) {
- if ($function($value, $element)) {
+function pieform_rule_required(Pieform $form, $value, $element, $check) {
+ if ($check) {
+ $function = 'form_is_empty_' . $element['type'];
+ if (function_exists($function)) {
+ if ($function($value, $element)) {
+ return $form->i18n('required');
+ }
+ return;
+ }
+
+ if ($value == '') {
return $form->i18n('required');
}
- return;
}
-
- if ($value == '') {
- return $form->i18n('required');
- }
}
?>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|