I have a controller like this:
def save = {
def conferenceUser = new ConferenceUser()
def conf_1 = Conference.get(params.conference.id)
def role_1 = Role.get(params.role.id)
def status_1 = Status.get(params.status.id)
def user_1 = User.get(params.user.id)
conferenceUser.conference = conf_1
conferenceUser.dateParticipated = params.dateParticipated
conferenceUser.accepted = params.accepted
conferenceUser.status = status_1
conferenceUser.role = role_1
conferenceUser.user = user_1
if (!conferenceUser.save(failOnError: true)) {
render (view: 'participatedAdd', model : [conferenceUser: conferenceUser])
return
render(view: 'participatedAdd2', model: [conferenceUser: conferenceUser])
}
}
Basically, this is the save controller of my 2-step registration phase. I want to be able to, after saving the first part, load the second view (participatedAdd2), but 开发者_StackOverflowI need to keep the conferenceUser.conference
value for the next controller action. How can I access this value in my second save2
controller action?
In your participatedAdd2
view, put a
<input type="hidden" name="conferenceUserId" value="${conferenceUser.id}"/>
in the form that gets submitted to the save2
action. You can then look up the ConferenceUser
in your save2
action with:
def conferenceUser = ConferenceUser.get(params.conferenceUserId)
精彩评论