Created
March 26, 2013 19:31
-
-
Save ddelponte/5248446 to your computer and use it in GitHub Desktop.
Handling associated form inputs in Grails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A form with associated inputs | |
<g:form action="seed"> | |
<g:each in="${teams}" status="i" var="team"> | |
<input type="hidden" name="teams.${i}.id" value="${team.id}"> | |
<input type="text" size="2" name="teams.${i}.seed" value="${team.seed}"> | |
</g:each> | |
<g:submitButton name="update" value="Update" /> | |
</g:form> | |
The controller: | |
log.error "params = ${params}" | |
params.teams.findAll {k,v -> !k.contains(".")}.each { k,v -> | |
bindData(Team.get(v.id), v) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment