[Feature Request] Default binding for Vector or IndexedSeq in play.api.data.Forms


In Play 2.6 the default Form bindings for repeated elements are seq, list and set, for example:

  "name" -> seq(text)

However there are many use cases where Vector collection type is more suitable since it has a better overall performance (such as for Index based Access). Why not consider a default binding for Vector or IndexedSeq since it’s considered one of the most versatile collections in Scala? The default implementation of Seq or Iterable in Scala is List. I would like to suggest a new Feature that would contain a Pull Request to add either Vector or IndexedSeq as one of the default bindings in play.api.data.Forms, such as:

  def vector[A](mapping: Mapping[A]): Mapping[Vector[A]] = RepeatedMapping(mapping).transform(_.toVector, _.toList)

  def indexedSeq[A](mapping: Mapping[A]): Mapping[IndexedSeq[A]] = RepeatedMapping(mapping).transform(_.toIndexedSeq, _.toList)

Hey @guilhebl,

I don’t see why not. Feel free to submit a pull request. :slight_smile: