Hi,

In the pages controller I've created an action called "contact" to
allow receiving messages from visitors and then this messages are
stored in the database. I have a field in the table contacts called
"mdate" which is dedicated for storing the MySQL datetime of the
message sent.

The mdate has no any fields in the contact forms. The following is
contact action code:
function contact(){
           $this->loadModel('Contact');
           if (!empty($this->data)){
           $this->Contact->create();
           if ($this->Contact->save($this->data)){
            $this->Session->setFlash(__('Contact Message has been
received.',true));
           }
           else{
            $this->Session->setFlash(__('Contact Message Could not be
sent!.',true));
           }
           }

        }
In the Contact model I set validate property as following:

<?php
class Contact extends AppModel{
    var $name = 'Contact';
    var $validate = array(
    'name' => array('notempty'),
    'email' => array('notempty','email'),
    'message' => array('notempty'),
    'mdate' => array('rule' =>'notEmpty','message'=>'no')
    );
}

You may notice at the last line mdate should be validated and it must
be not empty. However, the above contact action does not supply any
value for mdate and in-spite of this, records are added successfully
and mdate field does not have datetime values it is just recorded as
00-00-00 00:00:00 in the database.

My question is: Why Contact Model does not apply the validation rules
on the mdate field and stop creating the new record?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to