Skip to content

Instantly share code, notes, and snippets.

@benoit-ponsero
Created January 8, 2013 14:48
Show Gist options
  • Save benoit-ponsero/4484313 to your computer and use it in GitHub Desktop.
Save benoit-ponsero/4484313 to your computer and use it in GitHub Desktop.
@repeatWithIndex
@(field:Field, min:Int=1)(f: (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(myForm("field"), min=1) { (field, index) =>
@index
@helper.inputText(field("another_field"))
}
@alissapajer
Copy link

Thanks! Just used this successfully!

@techmag
Copy link

techmag commented Apr 13, 2015

Get's my vote... ran into a situation that required exactly this...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment