Date: 01/01/01
- Next message: Ulf Wendel: "Re: [phplib-dev] BUG: Transparent Session IDs + forms"
- Previous message: uw: "[phplib-dev] cvs commit"
- Next in thread: uw: "[phplib-dev] cvs commit"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
From: uw
Date: Mon Jan 1 16:01:36 2001
Modified files:
php-lib/pages/form/example_form.inc
Log message:
minor updates
Index: php-lib/pages/form/example_form.inc
diff -u php-lib/pages/form/example_form.inc:1.3 php-lib/pages/form/example_form.inc:1.4
--- php-lib/pages/form/example_form.inc:1.3 Tue Apr 18 13:57:41 2000
+++ php-lib/pages/form/example_form.inc Mon Jan 1 16:01:05 2001
@@ -10,12 +10,67 @@
// define/build the form
function Init() {
- // set the default size (text, textarea)
- $this->setSize(20);
- // set the default maxlength (text, textarea)
- $this->setMaxlength(100);
+ $this->setDefaults( array ( "textsize" => 20, "textmaxlength" => 100) );
+ // make sure to escape special characters!
+ $this->setJSError("Ooops some errors...\\n\\n", "\\n\\nPlease correct them...");
+
// define elements
+ $this->addElement(
+ array (
+ "name" => "dependencies",
+ "type" => "select",
+ "options" => array (
+ "0" => "validate everything",
+ "1" => "don't validate pass",
+ "5" => "don't validate pass, numbers and secret_numbers",
+ "7" => "don't care on length_e of pass and valid_e of textarea"
+ ),
+ "value" => "-1",
+
+ "intro" => array ( "-1" => "Custom validators..."),
+
+ "size" => 1,
+ "frozen" => false,
+ "multiple" => false,
+
+ "validator" => "DependencieValidator",
+ "js_validator" => 'function DependencieValidator(formobj) {
+
+ var i, v;
+
+ // get the value of the select box dependencies
+ with (document.forms[formobj.name].elements["dependencies"])
+ for (i = 0; i < options.length; i++)
+ if (options[i].selected) {
+ v = options[i].value;
+ break;
+ }
+
+ switch (v) {
+ case "1":
+ // do not validate the element pass
+ formobj.val_off("pass", "lri");
+ break;
+
+ case "5":
+ // do not validate pass, numbers and secret_numbers
+ formobj.val_off("pass", "lri");
+ formobj.val_off("numbers", "lri");
+ formobj.val_off("secret_numbers", "lri");
+ break;
+
+ case "7":
+ // turn off textarea regexp and pass length validation
+ formobj.val_off("textarea", "r");
+ formobj.val_off("pass", "l");
+ break;
+ }
+
+}'
+ )
+ );
+
$this->addElement( array (
"name" => "pass",
"type" => "password",
@@ -38,7 +93,7 @@
"frozen" => false,
"valid_e" => "Only numbers are allowed, no other characters.",
- "valid_regex" => "[0-9]+",
+ "valid_regex" => "^[0-9]+[\.,]?[0-9]*$",
"minlength" => 3,
"length_e" => "Enter at least 3 numbers."
@@ -48,12 +103,11 @@
$this->addElement( array (
"name" => "secret_numbers",
- "type" => "text",
- "pass" => true,
+ "type" => "password",
"frozen" => false,
"valid_e" => "Only numbers are allowed.",
- "valid_regex" => "[0-9]+",
+ "valid_regex" => "^[0-9]+[\.,]?[0-9]*$",
"minlength" => 3,
"length_e" => "Enter at least 3 numbers."
@@ -69,7 +123,7 @@
"rows" => 2,
"valid_e" => "Sorry, no other characters allowed but a-z/A-Z.",
- "valid_regex" => "[a-z]+",
+ "valid_regex" => "^[a-zA-Z ]+$",
"valid_icase" => true,
"minlength" => 10,
@@ -80,8 +134,8 @@
$this->addElement(
array (
- "name" => "file",
- "type" => "file",
+ "name" => "fileupload",
+ "type" => "fileupload",
"size" => 10,
"maxfilesize" => 100,
@@ -96,7 +150,7 @@
)
);
-
+/*
$this->addElement(
array (
"name" => "combo",
@@ -125,30 +179,6 @@
);
$this->addElement(
- array (
- "name" => "dependencies",
- "type" => "select",
- "options" => array (
- "0" => "validate everything",
- "1" => "don't validate pass",
- "5" => "don't validate pass, numbers and secret_numbers",
- "7" => "don't care on length_e of pass and valid_e of textarea"
- ),
- "value" => "-1",
-
- "intro" => array ( "-1" => "Custom validators..."),
-
- "size" => 1,
- "frozen" => false,
- "multiple" => false,
-
- // bind a custom validator on this element -
- // don't forget to write a method void DependencieValidator(void)
- "validator" => "DependencieValidator"
- )
- );
-
- $this->addElement(
array (
"name" => "treeview",
"type" => "tree",
@@ -157,7 +187,7 @@
"size" => 1,
"accesskey" => "accesskey",
- "tabindex" => "tabindex",
+ "tabindex" => 3,
"intro" => array( "-1" => "Please choose..."),
"intro_e" => "Please choose an option!",
@@ -227,7 +257,7 @@
)
)
);
-
+ */
$this->addElement(
array (
"name" => "check",
@@ -343,7 +373,7 @@
"frozen" => false
)
);
-
+/*
$this->addElement(
array (
"name" => "date_en",
@@ -362,9 +392,10 @@
"language" => "de"
)
);
+*/
// autoload the form with HTTP_[POST|GET]_VARS
$this->autoloadValues();
-
+
// All the new form classes have a method that dumps datastructures
// of objects and arrays. Use this function while debugging to get
// an idea of the internal datastructes
@@ -408,10 +439,6 @@
break;
}
- // creates a error message
- // $this->setValidationError( "dependencies",
-
- #$this->introspection($this->elements);
} // end func dependenciesdependencies
} // end class example_form
---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-dev-unsubscribe <email protected>
For additional commands, e-mail: phplib-dev-help <email protected>
- Next message: Ulf Wendel: "Re: [phplib-dev] BUG: Transparent Session IDs + forms"
- Previous message: uw: "[phplib-dev] cvs commit"
- Next in thread: uw: "[phplib-dev] cvs commit"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

