简体   繁体   中英

Params unknown (Play! Framework)

It's a bit early on a Sunday morning for this (sorry) but here goes.

The form I am working on is has a list of users (checkboxes) and some other fields below (dates, etc). The purpose of the form is to bulk add objects. So, for each of these checkboxes (users) add an object with the user and the dates.

The problem that I have is that I don't know how to capture the id's passed back through from params as I don't know the params names being passed through. Can you help?

You can use u_index if you are in a list tag to have an index for your users

In you view

#{list users, as:'u'}
  <input type="hidden" name="users[$[u_index -1].id" value="${u.id}">
#{/list}

and in your controller

public static void save(List<User> users) {
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM