This patch is to add support to validate fields using php code. This helps the
coder to write advanced validation code for cck text field. After patch
there is a new php code textfield created where we can put our validation code.
And if the field value provided is valid then we can return true, false otherwise.
Validation code example:
========
/* accessible variables : $node, $field, $item */
/* test the $item["value"] */
if(preg_match('/^\w\w*\.\w\w*\.\w\w*$/', $item['value'])) { /* see if www.sf.net for example */
return true; /* it is valid */
}
return false; /* not valid */
=========
I hope this will provide more freedom of validation to the coders :) .
Comment | File | Size | Author |
---|---|---|---|
text.module.patch | 2.05 KB | kamanashisroy |
Comments
Comment #1
mjlF95 CreditAttribution: mjlF95 commentedI'm trying to do this very thing in Drupal 5.x. I am running version 1.7 of CCK and I checked the contents of this patch against the text.module and it seems like it's been implemented in 1.7. However, I tried the above example code and it did not seem to effect validation (both www.xxxx.yyy and non-www.xxxx.yyy validated). Any advice?
Comment #2
KarenS CreditAttribution: KarenS commentedToo old now, way past the time when we will add features to D5 version.
Comment #3
kenorb CreditAttribution: kenorb commentedFollow-up: #912698: Validation on CCK Core
Comment #4
kenorb CreditAttribution: kenorb commented