Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This is a text field that uses a regular expression to validate the contents. Good for something like a name that's restricted to alpha only, or an IP address, etc.
Uses either PCRE or POSIX regular expressions (selectable with radio box).
Comment | File | Size | Author |
---|---|---|---|
#1 | regex_0.module | 11.72 KB | gregmac |
regex.module | 11.8 KB | gregmac |
Comments
Comment #1
gregmac CreditAttribution: gregmac commentedLeft some debug code in the module, removed
Comment #2
yched CreditAttribution: yched commentedThis seems like a good idea.
It probably implies a lot of code duplication, though.
Wouldn't it be better to envision this as a patch to text.module ?
(possibly with the field setting stuff folded in a fieldset to avoid form cluttering...)
I'm aware that patches to "native CCK bundle" currently take much longer to get committed, but I think we should try to avoid field modules duplication
(this is not a proper review of your module, sorry :-) )
Comment #3
gregmac CreditAttribution: gregmac commentedThis actually did start out as a patch to the text module, and I split it off into its own module for a couple reasons. The 'allowed values' field in text.module is redundant if you're using regex, so I didn't really know how to structure the interface in a way that wouldn't feel really kludgy (open to ideas though, of course). It's also something that not everyone will use (or in some cases, even want to provide available to clients/end-users).
There probably is some duplication, but this was my first module and look into drupal internals, so I'm not really sure what can be avoided (eg, if it's possible to call functions from text.module).
Comment #4
yched CreditAttribution: yched commentedA patch adding regex validation to text.module has just been submitted.
Maybe both efforts should be merged / coordinated ?
Comment #5
yched CreditAttribution: yched commentedand there's also
http://drupal.org/node/76467
Comment #6
yched CreditAttribution: yched commentedMy view ATM is that we should privilege the approach in the issue I mentiond in #4
http://drupal.org/node/84791 (option for text.module)
So I'm marking this thread as a duplicate - we can get back to it if we eventually find a separate module more appropriate. Thanks a lot for this work, gregmac, there is probably good things to steal from it anyway.
Comment #7
kenorb CreditAttribution: kenorb commented8.x: #52051: Validation API/UI