Output get_class($this->EnrolleesOfferedSubject) in your controller.
If it is AppModel cake cannot find your model file.

On Sep 8, 10:32 am, learning_cake_php <lunaro...@gmail.com> wrote:
> i already check my model names and codes...
> i have a controller named EnrollmentController and from there
> i used the $uses property for me to user the EnrolleesOfferedSubject
> model..
> why is it that save,create and delete method works just fine..saves
> and delete to/from
> correct table(enrollees_offered_subjects) but my custom method wont
> work..here is the actual code:
>
> //enrollment_controller.php
> <?
>         class EnrollmentController extends AppController {
>                 var $name = 'Enrollment';
>                 var $uses = array(
>                                                 'Enrollment',
>                                                 'Student',
>                                                 'EnrollmentPayment',
>                                                 'Enrollee',
>                                                 'OfferedSubject',
>                                                 'EnrolleesOfferedSubject',
>                                                 'Major',
>                                                 'Campus',
>                                                 'College',
>                                                 'Course',
>                                                 'Subject',
>                                                 'Program',
>                                                 'Scholarship',
>                                                 'Users'
>                                         );
>
>                 function subjectView(){
>                         $this->setCRUD('subject');
>
>                         
> $student=$this->Student->isStudent($this->Session->read
> ('Student.id'));
>                         if(!$student){
>                                 $this->Session->setFlash(__('Student Not 
> Found.', true));
>                                 $this->redirect(array('action'=>'index'));
>                         }
>
>                         $this->Session->write('Student.id', 
> $student['Student']['id']);
>                         $this->Session->write('Student.full_name', 
> $student['Student']
> ['last_name']
>                                                                               
>           .", ".$student['Student']['first_name']
>                                                                               
>           ." ".$student['Student']['middle_name']
>                                                                               
>           ." ".$student['Student']['sur_name']
>                                                                               
>           );
>
>                         
> $enrollmentPayment=$this->EnrollmentPayment->isPaid($this->Session-
>
> >read('Student.id'));
>
>                         if(!$enrollmentPayment){
>                                 $this->Session->setFlash(__('Not Yet Paid.', 
> true));
>                                 
> $this->redirect(array('action'=>'paymentAdd'));
>                         }
>
>                         
> $enrollee=$this->Enrollee->isEnrolled($this->Session->read
> ('Student.id'));
>
>                         if(!$enrollee){
>                                 $this->Session->setFlash(__('Student Not Yet 
> Enrolled.', true));
>                                 
> $this->redirect(array('action'=>'enrolleeAdd'));
>                         }
>
>                         $this->EnrolleesOfferedSubject->recursive = 0;
>                         //$this->EnrolleesOfferedSubject->unbindModel(array
> ('belongsTo'=>array('Enrollee','OfferedSubject')));
>                         
> $this->EnrolleesOfferedSubject->bindModel(array('belongsTo'=>array(
>                                         'Enrollee'=>array(
>                                                 'foreignKey'=>'enrollee_id',
>                                                 'type'=>'INNER'
>                                         ),
>                     'OfferedSubject'=>array(
>                         'foreignKey'=>'offered_subject_id',
>                                                 'type'=>'INNER'
>                                         ),
>                     'Subject'=>array(
>                         'foreignKey'=>false,
>                                                 'type'=>'INNER',
>                         'conditions'=> array('Subject.id =
> OfferedSubject.subject_id')
>                                         )
>                                         )
>                                 )
>                         );
>                         $this->set('student_full_name',$this->Session->read
> ('Student.full_name'));
>                         
> $this->set('student_id',$this->Session->read('Student.id'));
>                         $this->set('enrolleesOfferedSubjects', 
> $this->EnrolleesOfferedSubject->find('all', array(
>
>                                                 'conditions' => array(
>                                                         
> 'EnrolleesOfferedSubject.enrollee_id' => $enrollee['Enrollee']
> ['id'],
>                                                         
> 'EnrolleesOfferedSubject.campus_id' => $this->Enrollment->campusId,
>
>                                                         )
>                                                 )
>                                         )
>                                 );
>                 }
>                 function subjectResult(){
>                         Configure::write('debug', '0');
>                         $this->setCRUD('subject');
>                         $searchKey=trim($this->data['searchKey']);
>                         
> $student=$this->Student->isStudent($this->Session->read
> ('Student.id'));
>                         if(!$student){
>                                 $this->Session->setFlash(__('Session has 
> expired. Please click
> done and try again.', true));
>                         }elseif (!empty($searchKey)){
>                                 $this->OfferedSubject->recursive = 1;
>                                 $this->set('offeredSubjects', 
> $this->OfferedSubject->find
> ('all',array(
>                                                                               
>                   'conditions'=>array(
>                                                                               
>                           'and'=>array(
>                                                                               
>                                   'Subject.code LIKE 
> '=>$this->data['searchKey'].'%',
>                                                                               
>                                   'OfferedSubject.campus_id' => 
> $this->Enrollment->campusId
>
>                                                                               
>                           )
>                                                                               
>                   )
>                                                                               
>           )
>                                                                               
>   )
>                                                                         );
>                                 $this->set('total', 
> $this->OfferedSubject->find('count',array(
>                                                                               
>                   'conditions'=>array(
>                                                                               
>                           'and'=>array(
>                                                                               
>                                   'Subject.code LIKE 
> '=>$this->data['searchKey'].'%',
>                                                                               
>                                   'OfferedSubject.campus_id' => 
> $this->Enrollment->campusId
>
>                                                                               
>                           )
>                                                                               
>                   )
>                                                                               
>           )
>                                                                               
>   )
>                                                                         );
>                         }else{
>                                         $this->autoRender=false;
>                         }
>                         //$this->layout = 'ajax';
>                 }
>
>                 function subjectAdd($id = null, $subject = null){
>                         $this->setCRUD('subject');
>                         
> $student=$this->Student->isStudent($this->Session->read
> ('Student.id'));
>                         if(!$student){
>                                 $this->Session->setFlash(__('Student Not 
> Found.', true));
>                                 $this->redirect(array('action'=>'index'));
>                         }
>
>                         $this->Session->write('Student.id', 
> $student['Student']['id']);
>                         $this->Session->write('Student.full_name', 
> $student['Student']
> ['last_name']
>                                                                               
>           .", ".$student['Student']['first_name']
>                                                                               
>           ." ".$student['Student']['middle_name']
>                                                                               
>           ." ".$student['Student']['sur_name']
>                                                                               
>           );
>
>                         
> $enrollmentPayment=$this->EnrollmentPayment->isPaid($this->Session-
>
> >read('Student.id'));
>
>                         if(!$enrollmentPayment){
>                                 $this->Session->setFlash(__('Not Yet Paid.', 
> true));
>                                 
> $this->redirect(array('action'=>'paymentAdd'));
>                         }
>
>                         
> $enrollee=$this->Enrollee->isEnrolled($this->Session->read
> ('Student.id'));
>
>                         if(!$enrollee){
>                                 $this->Session->setFlash(__('Student Not Yet 
> Enrolled.', true));
>                                 
> $this->redirect(array('action'=>'enrolleeAdd'));
>                         }
>
>                         if (!$id || !$subject){
>                                 $this->Session->setFlash(__('Invalid Offered 
> Subject', true));
>                                 
> $this->redirect(array('action'=>'subjectView'));
>                         }
>
>                         $this->EnrolleesOfferedSubject->setValues(array(
>                                                                         
> 'enrollee_id'=> $enrollee['Enrollee']['id'],
>                                                                         
> 'offered_subject_id'=> $id ,
>                                                                         
> 'user_id'=>$this->Enrollment->userId,
>                                                                         
> 'campus_id'=>$this->Enrollment->campusId,
>                                                                         
> 'date_updated'=>date("Y-m-d g:i:s")
>                                                                         )
>                                                                 );
>
>                         $this->EnrolleesOfferedSubject->create();
>
>                         if 
> ($this->EnrolleesOfferedSubject->save($this->data)) {
>                                 $this->Session->setFlash(__($subject . ' has 
> been added', true));
>
>                         } else {
>                                 $this->Session->setFlash(__($subject. ' could 
> not be saved.
> Please, try again.', true));
>
>                         }
>                         $this->redirect(array('action'=>'subjectView'));
>                 }
>
>                 function subjectDelete($id = null, $subject = null){
>                         
> $student=$this->Student->isStudent($this->Session->read
> ('Student.id'));
>                         if(!$student){
>                                 $this->Session->setFlash(__('Student Not 
> Found.', true));
>                                 $this->redirect(array('action'=>'index'));
>                         }
>
>                         $this->Session->write('Student.id', 
> $student['Student']['id']);
>                         $this->Session->write('Student.full_name', 
> $student['Student']
> ['last_name']
>                                                                               
>           .", ".$student['Student']['first_name']
>                                                                               
>           ." ".$student['Student']['middle_name']
>                                                                               
>           ." ".$student['Student']['sur_name']
>                                                                               
>           );
>
>                         
> $enrollmentPayment=$this->EnrollmentPayment->isPaid($this->Session-
>
> >read('Student.id'));
>
>                         if(!$enrollmentPayment){
>                                 $this->Session->setFlash(__('Student Not Yet 
> Paid.', true));
>                                 
> $this->redirect(array('action'=>'paymentAdd'));
>                         }
>
>                         
> $enrollee=$this->Enrollee->isEnrolled($this->Session->read
> ('Student.id'));
>
>                         if(!$enrollee){
>                                 $this->Session->setFlash(__('Student Not Yet 
> Enrolled.', true));
>                                 
> $this->redirect(array('action'=>'enrolleeAdd'));
>                         }
>
>                         $this->EnrolleesOfferedSubject->setValues(array(
>                                                                         
> 'enrollee_id'=> $enrollee['Enrollee']['id'],
>                                                                         
> 'id'=> $id ,
>                                                                 )
>                                                         );
>                         if (!$id || !$subject) {
>                                 $this->Session->setFlash(__('Invalid id for 
> OfferedSubject',
> true));
>                                 
> $this->redirect(array('action'=>'subjectView'));
>                         }
>                         if ($this->EnrolleesOfferedSubject->del($id)) {
>                                 $this->Session->setFlash(__($subject . ' has 
> been deleted',
> true));
>                                 
> $this->redirect(array('action'=>'subjectView'));
>                         }else{
>                                 $this->Session->setFlash(__($subject . ' cant 
> be deleted', true));
>                                 
> $this->redirect(array('action'=>'subjectView'));
>                         }
>                 }
>
>         }
>
> ?>
>
> //enrollees_offered_subject.php
>
> <?php
> class EnrolleesOfferedSubject extends AppModel {
>
>         var $name = 'EnrolleesOfferedSubject';
>         var $validate = array(
>                 'enrollee_id' => array('numeric'),
>                 'offered_subject_id' => array('numeric'),
>         );
>
>         var $subjectLoadData = array();
>         //The Associations below have been created with all possible keys,
> those that are not needed can be removed
>
>         var $belongsTo = array(
>                 'Enrollee' => array(
>                         'className' => 'Enrollee',
>                         'foreignKey' => 'enrollee_id',
>                         'conditions' => '',
>                         'fields' => '',
>                         'order' => ''
>                 ),
>                 'OfferedSubject' => array(
>                         'className' => 'OfferedSubject',
>                         'foreignKey' => 'offered_subject_id',
>                         'conditions' => '',
>                         'fields' => '',
>                         'order' => ''
>                 ),
>                 'Campus' => array(
>                         'className' => 'Campus',
>                         'foreignKey' => 'campus_id',
>                         'type'=>'INNER',
>                         'conditions' => '',
>                         'fields' => '',
>                         'order' => ''
>                 )
>         );
>
>         function beforeDelete($cascade = false){
>                 $studentSubject = $this->find('first', array(
>                                 'conditions' => array(
>                                         'EnrolleesOfferedSubject.enrollee_id' 
> => $this->subjectLoadData
> ['enrollee_id'],
>                                         'EnrolleesOfferedSubject.id' => 
> $this->subjectLoadData['id']
>                                         )
>                                 )
>                         );
>                 if($studentSubject){
>                         return true;
>                 }else{
>                         return false;
>                 }
>         }
>
>         function beforeSave(){
>                 foreach($this->subjectLoadData as $field=>$value){
>                         $this->data['EnrolleesOfferedSubject'][$field]=$value;
>                 }
>                 return true;
>         }
>
>         function setValues($data=array()){
>                 $this->subjectLoadData=$data;
>         }
>
> }
>
> ?>
>
> cake cant find method setValues using EnrollmentController but surely
> works using EnrolleesOfferedSubjectsController..
> Dr. Loboto sir..please help..still stuck here...i already
> doublechecked all the model names,filenames,controller names..still
> got no idea whats happening...
--~--~---------~--~----~------------~-------~--~----~
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