sanfly 0 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? Link to post Share on other sites
jcombs_31 0 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 Link to post Share on other sites
smoseley 4 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; } } Link to post Share on other sites
alvin567 0 Posted May 30, 2012 Share Posted May 30, 2012 maybe you can add more method? Link to post Share on other sites
Recommended Posts
Archived
This topic is now archived and is closed to further replies.