例:あなたは「アメリカ」で検索しました
と検索結果ページに表示したいです。
以下のコードを記述したのですが、
MoviesController.phpで
public function results() {
$country_cond[] = array();
foreach ($this->request->data["Movie"]["country_id"] as $id) {
$country_cond[] = $id;
}
$country_list = $this->Movie->Country->find('list', Array('conditions' => Array('Country.id' => $country_cond)));
$this->set('movies', $this->paginate('Movie'));
$this->set('country_list', $country_list);
}
/View/Movies/results.ctpで
?php
foreach ($country_list as $country_name) {
echo $country_name;
echo '<br/>';
}
?>
以下のエラーがでてしまい、全く上手くいきません。
Notice (8): Undefined index: Movie [APP/Controller/MoviesController.php, line 135]
同じプラグインを使用している方で、問題の解決方法をご存知のかたがいましたら教えてください!
$country_list = $this->Movie->Country->find
↓
$country_list = $this->Movie->find
とか
よかったです。
2012/03/15 01:41:42ちなみに、上記のコードのforeach無駄ですよ。
以下で十分かと。
長い間、ありがとうございました。
2012/03/15 11:35:55たいへん参考になりました!!