I have two forms, notably for classes named User
and Company
. In the User
form, when the user finds that his/her own company is not already in DB, then he/she will create a new Company
. I have changed the save
action of the Company
controller to something like this :
def save() {
def companyInstance = new Company(params)
if (!companyInstance.save(flush: true)) {
render(view: "create", model: [companyInstance: companyInstance])
return
}
flash.message = message(code: 'default.created.message', args: [message(code: 'company.label', default: 'Company'), companyInstance.id])
redirect(controller:"user", action:"create")
}
That is after saving the new company, I'm redirecting to User
's create
action. However it works quite well, the user who have already entered some value (i.e before going to the Company
's create
action) are been missing in the User
form fields.
How do I retrieve the values back on the User
field?
Thanks in advance.
You can achieve this with Webflows. Webflow is a list of forms, one after another that keep state between them. This way you can go 'back' to User form later without loosing entered values. Webflows are not easy - it's for semi-advanced users.