sanfly Posted May 24, 2012 Share Posted May 24, 2012 In my Payment model I have the following var $payMethodAll = array( '0' => 'Cash On Arrival', '1' => 'Direct Debit', '2' => 'Post (Cheque Only)', '3' => 'Credit Card', '4' => 'Account Credit', '5' => 'Account Credit + Direct Debit' ); In my Bookings controller, I call this data: $pMethods = $this->Payment->payMethodAll; And I get the following error: Notice (: Undefined property: AppModel::$payMethodAll [APP\controllers\bookings_controller.php, line 180] This was working perfectly before but now all of a sudden is not. I have tried clearing my tmp/cache/models Im confused as to what the problem is, because in the bookings_controller I can use the model to get data from the database without issue: ie: $p = $this->Payment->find('all'); works perfectly so not an issue with not having 'Payment' listed in $uses in my controller, or the model name being incorrect... Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/263083-cakephp-problem-calling-info-from-a-model/ Share on other sites More sharing options...
jcombs_31 Posted May 27, 2012 Share Posted May 27, 2012 If you are calling this from your bookings controller and it is associated with your payments, you need to properly link. $this->Booking->Payment->payMethodAll Quote Link to comment https://forums.phpfreaks.com/topic/263083-cakephp-problem-calling-info-from-a-model/#findComment-1348997 Share on other sites More sharing options...
smoseley Posted May 29, 2012 Share Posted May 29, 2012 If you are calling this from your bookings controller and it is associated with your payments, you need to properly link. $this->Booking->Payment->payMethodAll Wrong? The OP's code looks right. Seems he's either missing $uses or the var isn't declared as a class param... class PaymentMethod extends AppModel { public $payMethodAll = array( '0' => 'Cash On Arrival', '1' => 'Direct Debit', '2' => 'Post (Cheque Only)', '3' => 'Credit Card', '4' => 'Account Credit', '5' => 'Account Credit + Direct Debit' ); ... } class BookingController extends AppController { public $uses = ("PaymentMethod"); public function myAction() { echo $this->PaymentMethod->payMethodAll; } } Quote Link to comment https://forums.phpfreaks.com/topic/263083-cakephp-problem-calling-info-from-a-model/#findComment-1349471 Share on other sites More sharing options...
alvin567 Posted May 30, 2012 Share Posted May 30, 2012 maybe you can add more method? Quote Link to comment https://forums.phpfreaks.com/topic/263083-cakephp-problem-calling-info-from-a-model/#findComment-1349739 Share on other sites More sharing options...
smoseley Posted May 30, 2012 Share Posted May 30, 2012 huh? Quote Link to comment https://forums.phpfreaks.com/topic/263083-cakephp-problem-calling-info-from-a-model/#findComment-1349762 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.