我有customers
(id, name) 和services
(id, title, isSubscription),我想在其中添加一个下拉列表add.ctp
,Customers
其中将包含所有titles
的Services
where isSubscription
is true
。我怎样才能做到这一点?
Customers
和之间没有关系Services
,它只会用特定客户和所选服务的customerServices
(customerid, serviceid) 表填充。id
id
这是我尝试过的:
在ServicesController.php
中add function
:
$services = $this->Services->find('list'); //the error is here because there is no relationship between Customers and Services
$this->set(compact('services'));
在add.ctp
中Template/Customers
:
$this->Form->control('category',array('options' => $services));
但我明白了:
在布尔值上调用成员函数 find()