Jup that was the way to go!
Mind you I was not against using a model, just didn't had one...
So I made a mail-model, and it validates email (and subject and text
not being empty)... I now use it on different places in my site via:
$this->Mail->set( $this->data );
if ($this->Mail->validates()) {
//do actions when validated
}
Sometimes I just need to validate an e-mail, without actually sending
a mail, for instance, to store just email of a client in a database, I
just manually populate the subject and text fields with dummy-text
just before, so they always pass the validation, and then the email
field is correctly validated!
Thanks!
On 21 okt, 05:15, "Dr. Loboto" <[email protected]> wrote:
> I think better create model (without table) even if you'll use it only
> for this validation. The only other "native" way I see is use
> multivalidate behavior with some of already existing model - but only
> if there is any model that logically connected with this action.
>
> http://bakery.cakephp.org/articles/view/multivalidatablebehavior-usin...http://snook.ca/archives/cakephp/multiple_validatable_behavior
>
> On Oct 20, 9:39 pm, Céryl <[email protected]> wrote:
>
> > Hello all,
>
> > On my site I have a contact page (which is just pages/contact, with a
> > small form where users can enter their name and some text. After
> > clicking the button, an action in my controller (Actually a loose
> > controller called mails_controller, without views and a model) is done
> > which sends the mail back to me with the text the users enter.
>
> > However, how can I validate stuff in this form without a model?
> > Specifically, I like to use the rule => email and rule => notEmpty
> > from the standard model validation, but I need them in my controller.
>
> > Is there a way to use them in a controller function (without creating
> > a model i'll probably never use) or should I just do the validation by
> > hand (i.e. checking if the emailadres looks like [email protected] with php
> > stringfunctions etc.)?
>
> > Thanks!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---