hello,

Here is a real newbie question :-)
i have created a model to do some validation on a simple form without a
db attached.

<?php
class Contact extends AppModel
{
var $name = 'Contact';
var $validate = array(
'email'=>VALID_EMAIL,
'name'=>VALID_NOT_EMPTY,
'content'=>VALID_NOT_EMPTY
);
var $useTable = false; //no db!
}
?>

i read that i have to use "validates" instead of "save" to perform
validation if i dont have a db attached.
in my controller i need to do something like

<?php
class ContactsController extends AppController {
  var $uses = null; //niente database
  //  var $uses = array('Contact');
  var $helpers = array('Html', 'Form','Text' );

  var $name = 'Contacts';

        function index() {
   $this->render("index","mylayout");
        }


        function send() {

if ($this->Contact->validates($this->data))
     {
//do something, sanitize, etc.
                $this->render("index","mylayout");
     }
     else
     {
    // validate errors

        $this->set('userMessage',"Error!");
         $this->render("index","myerrorlayout");
     }
        }
}
?>


but i get this error:

Notice: Undefined property: ContactsController::$Contact
Fatal error: Call to a member function validates() on a non-object

I am missing something?

There is somewere a snippet with a really simple form validation (w/o
database?)


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to