02.08 php saved
tmazur
Tags add more
 
Note
tmazur did not leave a note
  1. **MODEL**
  2.  
  3. <?php
  4. class PostComment extends AppModel {
  5.     var $validate = array(
  6.         'username' => array(
  7.             'required' => true,
  8.             'rule'=>'notEmpty',
  9.             'allowEmpty' => false
  10.         )
  11.     );
  12.     var $name = 'PostComment';
  13.     var $belongsTo = 'Post';
  14.    
  15.  
  16. }
  17. ?>
  18.  
  19. **CONTROLLER**
  20.  
  21. <?php
  22.  class PostCommentsController extends AppController {
  23.     var $name = 'PostComments';
  24.     var $scaffold = 'admin';
  25.    
  26.     function add(){
  27.         Configure::write ( 'debug', 1 );
  28.         if(!empty($this->data)){
  29.             $this->autoRender=true;
  30.             $this->layout='empty';
  31.             $this->PostComment->set( $this->data );
  32.             debug($this->PostComment->validates());
  33.             $error=$this->PostComment->save($this->data);
  34.            
  35.                 debug($error);
  36.             $x = $this->PostComment->read();
  37.             $this->set('data',$x['PostComment']);
  38.         }
  39.        
  40.     }
  41.  }
  42.  ?>
Parsed in 0.058 seconds, using GeSHi 1.0.7.14

Modify this Paste