Skip to content

Instantly share code, notes, and snippets.

@benoit-ponsero
Created January 8, 2013 14:48
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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"))
}
@jakob85
Copy link

jakob85 commented Jun 13, 2013

This is great! Thank you!

@cnicodeme
Copy link

This is perfect ! Thanks !

@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