Grails indexed parameters

前端 未结 4 1226
悲&欢浪女
悲&欢浪女 2020-12-28 10:10

I have a list of Team objects that have an Integer seed property. I want to edit all the teams\' seeds at once, in a single form. I\'m sure

4条回答
  •  一个人的身影
    2020-12-28 10:48

    I finally figured out how to do this without any shenanigans.

    Forget about the hidden parameter and just use the team ID in the seed parameter. In the GSP:

     
    ... 
       
         
       
     
    

    Then, in the controller:

    params.teams.seeds.each { teamId, seed ->
      def team = Team.get(teamId.toInteger())
      team.seed = seed.toInteger()
      team.save()
    }
    redirect(action:list)
    

    Works like a charm.

提交回复
热议问题