On 20-Oct-08, at 11:05 PM, Michael Prasuhn wrote:
I am building a directory listing type site and trying to keep all my listings in one node type.
I'm curious as to why CCK with a bunch of optional fields doesn't work for this. Could you not do a bit of custom PHP to validate fields within CCK?
One of the things I'd like to be able to do, is upon validation of the node, throw out any form values that do not match the type of listing they have chosen (so that the values won't be shown on the node preview, for example).
I don't think that's really the purpose of the validation hook. Typically, you should throw errors with form_set_error() to indicate why the data submitted is invalid. Even if you could make it work, I would think you'd have some pretty confused users wondering where their data went, thinking that the preview or the site was broken.
What is the best way to go about this?
Perhaps presave, or prepare hooks could do it? But based on the information you've given, I really think this is a solution for multiple content types + CCK. HTH, --Andrew