Skip to content

Instantly share code, notes, and snippets.

@shinobu-aoki
Created March 2, 2012 19:17
Show Gist options
  • Save shinobu-aoki/1960544 to your computer and use it in GitHub Desktop.
Save shinobu-aoki/1960544 to your computer and use it in GitHub Desktop.
Play2.0でBootstrap2.0
<div class="clearfix error" id="username_field">
<label for="username">Username:</label>
<div class="input">
<input type="text" name="username" id="username" value="">
<span class="help-inline">This field is required!, Another error</span>
<span class="help-block">Required, Another constraint</span>
</div>
</div>
<div class="control-group error" id="username_field">
<label class="control-label" for="username">Username</label>
<div class="controls">
<input type="text" id="username" name="username" value="">
<p class="help-inline">This field is required!, Another error</p>
<p class="help-block">Required, Another constraint</p>
</div>
</div>
@(elements: views.html.helper.FieldElements)
@import play.api.i18n._
@import views.html.helper._
<div class="control-group @elements.args.get('_class) @if(elements.hasErrors) {error}" id="@elements.args.get('_id).getOrElse(elements.id + "_field")">
<label class="control-label" for="@elements.id">@elements.label(elements.lang)</label>
<div class="controls">
@elements.input
@if(elements.errors.length > 0) {<span class="help-inline">@elements.errors(elements.lang).mkString(", ")</span>}
@if(elements.infos.length > 0) {<p class="help-block">@elements.infos(elements.lang).mkString(", ")</p>}
</div>
</div>
package views
import views.html.bootstrapField
import views.html.helper.FieldConstructor
object BootstrapHelper {
implicit val bootstrapConstructor = FieldConstructor(bootstrapField.f)
}
@(elements: views.html.helper.FieldElements)
@import play.api.i18n._
@import views.html.helper._
<div class="control-group @elements.args.get('_class) @if(elements.hasErrors) {error}" style="border-style: dashed;" id="@elements.args.get('_id).getOrElse(elements.id + "_field")">
<label class="control-label" for="@elements.id">@elements.label(elements.lang)</label>
<div class="controls">
@elements.input
@if(elements.errors.length > 0) {<span class="help-inline">@elements.errors(elements.lang).mkString(", ")</span>}
@if(elements.infos.length > 0) {<p class="help-block">@elements.infos(elements.lang).mkString(", ")</p>}
</div>
</div>
<dl class="error" id="username_field">
<dt><label for="username"><label>Username:</label></dt>
<dd><input type="text" name="username" id="username" value=""></dd>
<dd class="error">This field is required!</dd>
<dd class="error">Another error</dd>
<dd class="info">Required</dd>
<dd class="info">Another constraint</dd>
</dl>
@shinobu-aoki
Copy link
Author

blog用のコードを置いてます。
http://d.hatena.ne.jp/shinobu_aoki/20120302/1330716992

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