我有两个实体:Event和Person。
我有两个gsp页面,允许我创建事件和人员。在活动页面中,我可以选择现有人员,或者我可以插入姓名,姓名和电话号码。
我会有一个按钮,如果填写了三个字段,则允许我跳转到创建Person的页面,其中三个字段填充了在Event页面中插入的数据。
我尝试使用以下标签:
<g:link controller="patient" action="create"
params="[name: eventInstance.patientName, surname: eventInstance.patientSurname,
phone_1: eventInstance.phoneNumber]">link</g:link>
但这样参数是空的。
有什么建议吗?
编辑: 我尝试了以下内容:
<g:actionSubmit value="createPatient" action="createPatient"></g:actionSubmit>
,行动是:
def createPatient()
{
def eventInstance = new Event(params)
println("params are "+ params)
redirect(controller: "patient", action: "create", params: [name: "name", surname:
"surname", phone_1: "025-84569"] )
}
通过这种方式,执行了Create操作,我看到gsp页面的表单预先填充了参数传递。事实是params
没有我想要传递给create.gsp的值(所需的值是patientName,patientSurname和phoneNumber)。事实上,println()
告诉我:
params are [_action_createPatient:createPatient, recurInterval:1, recurCount:,
recurType:DAILY, endTime:, recurEndOption:never, recurUntil:, startTime:, title:,
patient_textField:, healthService.id:1, healthService:[id:1], patientName:,
phoneNumber:, description:, _recurDaysOfWeek:[, , , , , , ], patientSurname:,
patient_id:, action:save, controller:event]