# untuk process dropdown function afterFind($results) { // load Package model here App::import('Model','Package'); $this->PackageNumber = new PackageNumber(); $this->PackageNumber->recursive = -1; #App::import('Helper', 'Time'); #$time = new TimeHelper(); # loop data foreach ($results as $key => $val) { # $val akan beri nilai package_no_id # assign var baru nama title if(!empty($val['SelectedSubcon']['package_no_id'])){ $package_id = $val['SelectedSubcon']['package_no_id']; $package = $this->PackageNumber->read('title', $package_id); $results[$key]['SelectedSubcon']['package_no_id'] = $package['PackageNumber']['title']; } } return $results; }
Wednesday, September 30, 2009
Contoh afterFind call back dalam CakePHP
Kod di bawah diletakkan di dalam model untuk mengubahsuai data yang dihantar supaya memasukkan data dari table lain untuk kegunaan dropdown menggunakan find('list')
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment