Getting these error and I can not find a away to fix:
----------------------------------------------------------------------
----------------------------------------------------------------------
Notice (8): Undefined property: ContactsController::$Contact [APP/
controllers/contacts_controller.php, line 18]

Fatal error: Call to a member function set() on a non-object in /home/
www/........./cakephp_1.3.1/app/controllers/contacts_controller.php on
line 18
----------------------------------------------------------------------
---------------------------------------------------------------------

The erro is generated with this line - $this->Contact->set($this-
>data);
and if I hide this section this line ( if( $this->Contact-
>validates() ){ ) creates same error

I have FORM page that user can enter name, email and some comment and
submit.
I just send email and not using database (I want to use just
validation at controller).

It seems like validation is not working properly and I don't know why.

I look at this page:
http://book.cakephp.org/view/1182/Validating-Data-from-the-Controller

contact.php
============================
<?php
class Contact extends AppModel {
        var $name = 'Contact';
        var $useTable = false;

        var $validate = array(
                'name'=>array(
                        'no_empty'=>array(
                                'rule'=>VALID_NOT_EMPTY,
                                'message'=>'Please enter name')
                )
                'email'=>array(
                        'no_empty'=>array(
                                'rule'=>VALID_NOT_EMPTY,
                                'message'=>'Please enter email'
                        ),
                        'emailchk'=>array(
                                'rule'=>VALID_EMAIL,
                                'message'=>'Please enter valid email address'
                        )
                )
        );
}
?>
============================


controller file- contacts_controller.php
============================
<?php
class ContactsController extends AppController {
        var $name = "Contacts";
        var $helpers = array('Form', "Session");
        var $components = array("Email");

        function index(){
                 if(!empty($this->data)){
                       $this->Contact->set($this->data);

                        if( $this->Contact->validates() ){
                                //   sending email code here
                                $this->redirect(array('controller' => 
'contacts', 'action'
=> 'thank_you'));
                        }
                   }
        }

        function thank_you(){}
}
?>
============================

view - index.ctp
============================
 <?php echo $form->create("Contact", array("action"=>"index",
"type"=>"post", "name"=>""))?>

 Name: <?php echo $form->input('Contact.name', array('type'=>'text',
                                                                         
'label' => false,
                                                                          
'size'=>30))?>
Email: <span>*</span></label></th><td><div class="inputWrap">
            <?php echo $form->input('Contact.email', array('label' =>
false,
                                                                                
  'size'=>100))?>
             <?php echo $html->submit('submit'); ?>

 <?php echo $this->Form->end();?>
============================


Could someone can tell why ? this is not working??

Thanks

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to