0

我有customers(id, name) 和services(id, title, isSubscription),我想在其中添加一个下拉列表add.ctpCustomers其中将包含所有titlesServiceswhere isSubscriptionis true。我怎样才能做到这一点?

Customers和之间没有关系Services,它只会用特定客户和所选服务的customerServices(customerid, serviceid) 表填充。idid

这是我尝试过的:

ServicesController.phpadd function

$services = $this->Services->find('list'); //the error is here because there is no relationship between Customers and Services
$this->set(compact('services'));

add.ctpTemplate/Customers

$this->Form->control('category',array('options' => $services));

但我明白了:

在布尔值上调用成员函数 find()

4

1 回答 1

0

该文档包含一个标题为“获取表类实例”的部分,它准确地显示了您需要的内容:

TableRegistry::getTableLocator()->get('Services')->find(...)
于 2018-09-26T15:31:42.550 回答