Last active
December 23, 2015 20:09
-
-
Save nlochschmidt/6687635 to your computer and use it in GitHub Desktop.
hack to use Play 2.2 form helper with Bootstrap 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@(elements: views.html.helper.FieldElements) | |
@************************************************** | |
* Generate input according twitter bootsrap rules * | |
**************************************************@ | |
<div class="input-group @elements.args.get('_class) @if(elements.hasErrors) {has-error}" id="@elements.args.get('_id).getOrElse(elements.id + "_field")"> | |
<label class="sr-only" for="@elements.id">@elements.label(elements.lang)</label> | |
@elements.input | |
<div class="control-label" for="@elements.id">@elements.errors(elements.lang).mkString(", ")</div> | |
</div> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package views.html.helper | |
import views.html.helper.bootstrap.bootstrapFieldConstructor | |
package object twitterBootstrap3 { | |
implicit val twitterBootstrapField = new FieldConstructor { | |
def apply(elts: FieldElements) = bootstrapFieldConstructor(elts) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import helper.twitterBootstrap3._ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Put bootstrapFieldConstructor.scala.html and package.scala in app/views/helper/bootstrap and paste the one-liner into the scala template that creates the form