Comments (4)
Hmm perhaps I solved it by extending, is this correct to use:
@(field: play.api.data.Field, args: (Symbol,Any)*)(implicit handler: b3.B3FieldConstructor)
@b3.inputFormGroup(field, withFeedback = false, withLabelFor = true, b3.Args.withDefault(args, 'class -> "")) { fieldInfo =>
<div class="checkbox">
<label for="@fieldInfo.id">
<input type="checkbox" id="@fieldInfo.id" name="@fieldInfo.name" @if(fieldInfo.value == Some("true")){ checked } @toHtmlArgs(fieldInfo.innerArgsMap)>
</label>
</div>
}
from play-bootstrap.
Sorry, but I don't understand your question. A checkbox
will work with value="true"
as default, and a radio
uses a Seq[(String, Any)]
, so you could use simply something like Seq("true"->"True","false"->"False")
.
Play will handle the true
and false
strings as the corresponding boolean.
Then, the following code
@b3.checkbox( form("foo"), '_text -> "Remember me" )
@b3.radio( form("foo"), options = Seq("true"->"True","false"->"False"), '_label -> "Radio Group" )
will be rendered as:
<div class="form-group" id="foo_field">
<div class="checkbox">
<label for="foo">
<input type="checkbox" id="foo" name="foo" value="true">
Remember me
</label>
</div>
</div>
<div class="form-group" id="foo_field">
<label class="control-label ">Radio Group</label>
<div class="radio">
<label class="" for="foo_true">
<input type="radio" id="foo_true" name="foo" value="true">
True
</label>
</div>
<div class="radio">
<label class="" for="foo_false">
<input type="radio" id="foo_false" name="foo" value="false">
False
</label>
</div>
</div>
from play-bootstrap.
@adrianhurt Yes it works like you described. I did not know that Seq("true"->"True","false"->"False")
will work because of the signature Seq[(String, Any)]
.
I tried the following but that did not worked for radio inputs: Seq("1"->"True","0"->"False")
.
I will close this issue since the real problem is my Scala knowledge 😆
from play-bootstrap.
Don't worry ;) And yes, I think you had a little confusion but not with Scala. Note that everything will be finally rendered as a simple String
for HTML
. That's the reason to use (String, Any)
values (where any Any
value will call its toString
function.
from play-bootstrap.
Related Issues (20)
- fooForm in all the examples HOT 2
- Make my own radio button? HOT 1
- Install / Usage instructions HOT 1
- Unsure on how to use, getting errors HOT 2
- Release 1.4 HOT 8
- Checkbox label in horizontal form not vertically aligned HOT 1
- documentation misses class "position-relative" for feedback tooltip HOT 1
- Play 2.7 support (and cross build for Scala 2.13.0-M5) HOT 23
- Combining @multifield and @repeat HOT 4
- Display invalid-feedback HOT 4
- How do you pass the labelClass class radio-inline to a radioOption? HOT 3
- Messages are translated twice HOT 9
- Play 2.8 HOT 12
- Checkbox error text is always hidden HOT 1
- classes on b4.date not added correctly HOT 1
- How to set data-browse attribute at custom-file input HOT 2
- Cannnot select default option in select input HOT 1
- using custom file input, .invalid-feedback not shown. HOT 1
- Support for Bootstrap 5 HOT 3
- Option to handle translated strings as HTML
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from play-bootstrap.