1

I have a contact form that doesn't use a model. What's the best way to validate its data?

Should I use cake's automagic goodness and have it create a dummy model on the fly a pre-defined dummy model that validates the data according to the rules I add on the fly or is there a better way?

1 Answer 1

3

From my experience, it has always been that you create a model for situations like these, and then set:

var $useTable = false;

in the model. You don't have to do it "on-the-fly". It's just a model with validation rules, without an associated table.

Here's a link that should help you with this.

Sign up to request clarification or add additional context in comments.

1 Comment

And I always thought that it's quicker and better to skip the model and use some hacky validation inside the controller action. Really, what was I thinking? Thanks a lot for making this a lot more clearer to me! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.