Advice on CCK field validation

Events happening in the community are now at Drupal community events on www.drupal.org.
dddbbb's picture

Hi folks. Can anyone give me any advice on CCK field validation?

The CCK Validation module apparently seems to do what I need but is only available for Drupal 5 (I'm developing in Drupal 6). All I need to do is check if some user entered text contains a certain string and display a custom error message in place if that condition isn't met.

Sorry if it's a bit of a noob question.

Cheers.

Comments

Have you tried changing the

jamestombs's picture

Have you tried changing the .info of the 5.x release to 6.x and seeing if it worked?

I don't know how much CCK has changed from D5 to D6, but there is a chance that it will just work as is.

Alternatively you could look at the Rules module (http://drupal.org/project/rules) which should be able to do what you want.

James Tombs

Thanks

dddbbb's picture

I'm not sure I'm cool with getting stuck using a D5 module in D6 (let alone D7).

I'll take a look at the Rules module. Here's hoping the documentation is good!

Cheers.

Trying out Rules module but have another question

dddbbb's picture

Thanks James, it looks like the Rules module is exactly what I need (and generally a very powerful module to learn anyway). I'm stumbling at a certain point though and wonder if anyone can point me in the right direction?

My question:

Using textual comparison, how do you bring in the content of a particular field? I have element IDs switched on and am aware of the ID I need to use but still I'm having troubles. I need to do something like this:

--

Two texts to compare: *

the text that's been entered into the body field - body_field[body]

the string I'm checking for

--

Can someone point me in the right direction? Initially it would be nice to just get a direct comparison working, then I can start looking at regex for more nifty validation.

Cheers.

All sorted

dddbbb's picture

If it helps anyone...

Textual comparison couldn't quite manage what I wanted to do.

I managed to get round it using a combination of Rules' "execute custom PHP code" option and the Devel tab that the Devel module provides for each published node (this helped me figure out how to get the value out of the CCK field in question).

Brighton

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: