Using Play and the play-bootstrap plugin, how does one make an empty to show on a page?
That is, if I have a data object Something
, how do I make an empty form for it using play-bootstrap, so that user's can make a new Something
?
(Consider a Comment, say, instead of a Something
- not to edit, to create).
In your Controller class, for whichever method is loading the page you want to see (and this is using Java)
Where
twirlFile
is thetwirlFile.scala.html
template you want to use.Within that you need some code that looks like this:
As a bonus, if you didn't have any empty form, and wanted to put a hidden id in your form (representing the
id
field in `Something), add in:So your form would then look like: