Skip to content

Instantly share code, notes, and snippets.

@imeredith
Created June 20, 2012 12:44
Show Gist options
  • Save imeredith/2959722 to your computer and use it in GitHub Desktop.
Save imeredith/2959722 to your computer and use it in GitHub Desktop.
def repeatWithIndex(field: play.api.data.Field, min: Int = 1)(f: (play.api.data.Field, Int) => Html) = {
(0 until math.max(if (field.indexes.isEmpty) 0 else field.indexes.max + 1, min)).map(i => f(field("[" + i + "]", i)))
}
@repeatWithIndex(field, 3) { (field, index) =>
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment