grails multiple select:值不存储在相关对象中

grails multiple select:值不存储在相关对象中,select,grails,multi-select,Select,Grails,Multi Select,我有一个多重选择,如下所示: <g:select name="receiptItems" from="${HealthService.findAllByDoctor(Doctor.findBySecUser(new ReceiptController().getCurrentlyLoggedUser()))}" multiple="multiple" optionKey="id" optionValue="${{it.healthSe

我有一个多重选择,如下所示:

<g:select name="receiptItems" from="${HealthService.findAllByDoctor(Doctor.findBySecUser(new ReceiptController().getCurrentlyLoggedUser()))}"
              multiple="multiple" optionKey="id"
              optionValue="${{it.healthServiceType.healthService}}"
              size="5" value="${receiptInstance?.healthServices*.id}" class="many-to-many"
              onchange="${remoteFunction(
                      controller: 'Receipt',
                      action: 'sumReceiptItems',
                      params: '\'receiptItemsSelected=\' + jQuery(this).val()',
                      onSuccess: 'updateTotalAmount(\'totalAmount\', data, \'00000\')')}"/>
但我有同样的结果。 有什么建议吗?

您将选择标记命名为“receiptItems”,因此在控制器中检查该参数,然后将其添加到receiptInstance:


在保存receiptInstance之前,控制器中的具体位置在save()方法中
receiptInstance?.healthServices.collect{it.id}
params?.receiptItems?.each {
    def service = HealthService.get(it)
    receiptInstance.addToHealthServices(service)
}