diff --git a/core-play27/app/views/bs/package.scala b/core-play27/app/views/bs/package.scala index 09b273e..057a6a6 100644 --- a/core-play27/app/views/bs/package.scala +++ b/core-play27/app/views/bs/package.scala @@ -33,22 +33,22 @@ package object bs { val argsMap: Map[Symbol, Any] = Args.withoutNones(args).toMap /* Id of the input */ - val id: String = argsMap.get('id).map(_.toString).getOrElse(field.id) + val id: String = argsMap.get(Symbol("id")).map(_.toString).getOrElse(field.id) /* Id of the form-group */ - val idFormField: String = argsMap.get('_id).map(_.toString).getOrElse(id + "_field") + val idFormField: String = argsMap.get(Symbol("_id")).map(_.toString).getOrElse(id + "_field") /* The optional label */ - val labelOpt: Option[Any] = argsMap.get('_label).orElse(argsMap.get('_hiddenLabel)) + val labelOpt: Option[Any] = argsMap.get(Symbol("_label")).orElse(argsMap.get(Symbol("_hiddenLabel"))) /* Indicates if the label must be hidden */ - val hideLabel: Boolean = isTrue(argsMap, '_hideLabel) || argsMap.contains('_hiddenLabel) + val hideLabel: Boolean = isTrue(argsMap, Symbol("_hideLabel")) || argsMap.contains(Symbol("_hiddenLabel")) /* Name of the input */ def name: String = field.name /* Value of the input */ - val value: Option[String] = field.value.orElse(argsMap.get('value).map(_.toString)) + val value: Option[String] = field.value.orElse(argsMap.get(Symbol("value")).map(_.toString)) /* List with every error and its corresponding ARIA id. Ex: ("foo_error_0" -> "foo error") */ val errors: Seq[(String, Any)] = BSFieldInfo.errors(Some(field), argsMap, msgsProv).zipWithIndex.map { @@ -56,7 +56,7 @@ package object bs { } /* Indicates if there is any error */ - val hasErrors: Boolean = !errors.isEmpty || ArgsMap.isNotFalse(argsMap, '_error) + val hasErrors: Boolean = !errors.isEmpty || ArgsMap.isNotFalse(argsMap, Symbol("_error")) /* The optional validation state ("success", "warning" or "error") */ lazy val status: Option[String] = BSFieldInfo.status(hasErrors, argsMap) @@ -74,14 +74,14 @@ package object bs { /* List with every error */ def errors(maybeField: Option[Field], argsMap: Map[Symbol, Any], msgsProv: MessagesProvider): Seq[Any] = { - argsMap.get('_error).filter(!_.isInstanceOf[Boolean]).map { + argsMap.get(Symbol("_error")).filter(!_.isInstanceOf[Boolean]).map { _ match { case Some(FormError(_, message, args)) => Seq(msgsProv.messages(message, args.map(a => translate(a)(msgsProv)): _*)) case FormError(_, message, args) => Seq(msgsProv.messages(message, args.map(a => translate(a)(msgsProv)): _*)) case message => Seq(translate(message)(msgsProv)) } }.getOrElse { - maybeField.filter(_ => argsMap.get('_showErrors) != Some(false)).map { field => + maybeField.filter(_ => argsMap.get(Symbol("_showErrors")) != Some(false)).map { field => field.errors.map { e => msgsProv.messages(e.message, e.args.map(a => translate(a)(msgsProv)): _*) } }.getOrElse(Nil) } @@ -89,15 +89,15 @@ package object bs { /* List with every "feedback info" except "errors" */ def feedbackInfosButErrors(argsMap: Map[Symbol, Any], msgsProv: MessagesProvider): Seq[Any] = { - argsMap.get('_warning).filter(!_.isInstanceOf[Boolean]).map(m => Seq(translate(m)(msgsProv))).getOrElse( - argsMap.get('_success).filter(!_.isInstanceOf[Boolean]).map(m => Seq(translate(m)(msgsProv))).getOrElse(Nil) + argsMap.get(Symbol("_warning")).filter(!_.isInstanceOf[Boolean]).map(m => Seq(translate(m)(msgsProv))).getOrElse( + argsMap.get(Symbol("_success")).filter(!_.isInstanceOf[Boolean]).map(m => Seq(translate(m)(msgsProv))).getOrElse(Nil) ) } /* List with every "help info", i.e. a help text or constraints */ def helpInfos(maybeField: Option[Field], argsMap: Map[Symbol, Any], msgsProv: MessagesProvider): Seq[Any] = { - argsMap.get('_help).map(m => Seq(translate(m)(msgsProv))).getOrElse { - maybeField.filter(_ => argsMap.get('_showConstraints) == Some(true)).map { field => + argsMap.get(Symbol("_help")).map(m => Seq(translate(m)(msgsProv))).getOrElse { + maybeField.filter(_ => argsMap.get(Symbol("_showConstraints")) == Some(true)).map { field => field.constraints.map(c => msgsProv.messages(c._1, c._2.map(a => translate(a)(msgsProv)): _*)) ++ field.format.map(f => msgsProv.messages(f._1, f._2.map(a => translate(a)(msgsProv)): _*)) }.getOrElse(Nil) } @@ -107,9 +107,9 @@ package object bs { def status(hasErrors: Boolean, argsMap: Map[Symbol, Any]): Option[String] = { if (hasErrors) Some("error") - else if (ArgsMap.isNotFalse(argsMap, '_warning)) + else if (ArgsMap.isNotFalse(argsMap, Symbol("_warning"))) Some("warning") - else if (ArgsMap.isNotFalse(argsMap, '_success)) + else if (ArgsMap.isNotFalse(argsMap, Symbol("_success"))) Some("success") else None @@ -117,14 +117,14 @@ package object bs { /* Generates automatically the input attributes for the constraints of a field */ def constraintsArgs(field: Field, msgsProv: MessagesProvider): Seq[(Symbol, Any)] = field.constraints.map { - case ("constraint.required", params) => Some(('required -> true)) - case ("constraint.min", params: Seq[Any]) => Some(('min -> msgsProv.messages(params.head.toString))) - case ("constraint.max", params: Seq[Any]) => Some(('max -> msgsProv.messages(params.head.toString))) - case ("constraint.minLength", params: Seq[Any]) => Some(('minlength -> msgsProv.messages(params.head.toString))) - case ("constraint.maxLength", params: Seq[Any]) => Some(('maxlength -> msgsProv.messages(params.head.toString))) + case ("constraint.required", params) => Some((Symbol("required") -> true)) + case ("constraint.min", params: Seq[Any]) => Some((Symbol("min") -> msgsProv.messages(params.head.toString))) + case ("constraint.max", params: Seq[Any]) => Some((Symbol("max") -> msgsProv.messages(params.head.toString))) + case ("constraint.minLength", params: Seq[Any]) => Some((Symbol("minlength") -> msgsProv.messages(params.head.toString))) + case ("constraint.maxLength", params: Seq[Any]) => Some((Symbol("maxlength") -> msgsProv.messages(params.head.toString))) case ("constraint.pattern", params: Seq[Any]) => params.head match { - case str: String => Some(('pattern -> msgsProv.messages(str))) - case func: Function0[_] => Some(('pattern -> msgsProv.messages(func.asInstanceOf[() => scala.util.matching.Regex]().toString))) + case str: String => Some((Symbol("pattern") -> msgsProv.messages(str))) + case func: Function0[_] => Some((Symbol("pattern") -> msgsProv.messages(func.asInstanceOf[() => scala.util.matching.Regex]().toString))) case _ => None } case _ => None @@ -154,7 +154,7 @@ package object bs { } /* Indicates if there is any error */ - val hasErrors: Boolean = !errors.isEmpty || ArgsMap.isNotFalse(argsMap, '_error) + val hasErrors: Boolean = !errors.isEmpty || ArgsMap.isNotFalse(argsMap, Symbol("_error")) /* The optional validation state ("success", "warning" or "error") */ lazy val status: Option[String] = BSFieldInfo.status(hasErrors, argsMap) diff --git a/play27-bootstrap3/module/app/views/b3/bsFieldConstructorCommon.scala.html b/play27-bootstrap3/module/app/views/b3/bsFieldConstructorCommon.scala.html index 7056c03..f4bd2ca 100644 --- a/play27-bootstrap3/module/app/views/b3/bsFieldConstructorCommon.scala.html +++ b/play27-bootstrap3/module/app/views/b3/bsFieldConstructorCommon.scala.html @@ -1,5 +1,5 @@ @(fieldInfo: b3.B3FieldInfo, inputHtml: Html)(wrap: Html => Html)(implicit fc: b3.B3FieldConstructor) -
@text
}(fc, messages) \ No newline at end of file diff --git a/play27-bootstrap3/module/app/views/b3/textarea.scala.html b/play27-bootstrap3/module/app/views/b3/textarea.scala.html index b1370eb..044324b 100644 --- a/play27-bootstrap3/module/app/views/b3/textarea.scala.html +++ b/play27-bootstrap3/module/app/views/b3/textarea.scala.html @@ -1,4 +1,4 @@ @(field: Field, args: (Symbol,Any)*)(implicit fc: b3.B3FieldConstructor, messages: MessagesProvider) -@inputFormGroup(field, withFeedback = false, withLabelFor = true, bs.Args.withAddingStringValue(args, 'class, "form-control")) { fieldInfo => +@inputFormGroup(field, withFeedback = false, withLabelFor = true, bs.Args.withAddingStringValue(args, Symbol("class"), "form-control")) { fieldInfo => }(fc, messages) \ No newline at end of file diff --git a/play27-bootstrap3/module/app/views/b3/vertical/bsFormGroup.scala.html b/play27-bootstrap3/module/app/views/b3/vertical/bsFormGroup.scala.html index f78da2a..73468db 100644 --- a/play27-bootstrap3/module/app/views/b3/vertical/bsFormGroup.scala.html +++ b/play27-bootstrap3/module/app/views/b3/vertical/bsFormGroup.scala.html @@ -1,7 +1,7 @@ @(contentHtml: Html, argsMap: Map[Symbol, Any])(implicit messages: MessagesProvider) @b3.bsFormGroupCommon(contentHtml, argsMap) { content => - @argsMap.get('_label).map { label => - + @argsMap.get(Symbol("_label")).map { label => + } @content } \ No newline at end of file diff --git a/play27-bootstrap3/module/app/views/b3/vertical/package.scala b/play27-bootstrap3/module/app/views/b3/vertical/package.scala index b8a0e96..c2a57a2 100644 --- a/play27-bootstrap3/module/app/views/b3/vertical/package.scala +++ b/play27-bootstrap3/module/app/views/b3/vertical/package.scala @@ -55,11 +55,11 @@ package object vertical { * ********************************************************************************************************************************* */ def form(action: Call, args: (Symbol, Any)*)(body: VerticalFieldConstructor => Html) = { - val vfc = fieldConstructorSpecific(withFeedbackIcons = isTrue(args, '_feedbackIcons)) + val vfc = fieldConstructorSpecific(withFeedbackIcons = isTrue(args, Symbol("_feedbackIcons"))) views.html.b3.form(action, args: _*)(body(vfc))(vfc) } def formCSRF(action: Call, args: (Symbol, Any)*)(body: VerticalFieldConstructor => Html)(implicit request: RequestHeader) = { - val vfc = fieldConstructorSpecific(withFeedbackIcons = isTrue(args, '_feedbackIcons)) + val vfc = fieldConstructorSpecific(withFeedbackIcons = isTrue(args, Symbol("_feedbackIcons"))) views.html.b3.formCSRF(action, args: _*)(body(vfc))(vfc, request) } diff --git a/play27-bootstrap3/module/test/FieldConstructorsSpec.scala b/play27-bootstrap3/module/test/FieldConstructorsSpec.scala index 11d20ad..3ee39af 100644 --- a/play27-bootstrap3/module/test/FieldConstructorsSpec.scala +++ b/play27-bootstrap3/module/test/FieldConstructorsSpec.scala @@ -68,21 +68,21 @@ object FieldConstructorsSpec extends Specification { } "allow setting a custom id" in { - simpleInputWithArgs('_id -> "customid") must contain("id=\"customid\"") + simpleInputWithArgs(Symbol("_id") -> "customid") must contain("id=\"customid\"") } "allow setting extra classes form-group" in { - clean(simpleInputWithArgs('_class -> "extra_class another_class")) must contain(s"""theText
") + b3.static("theLabel", Symbol("class") -> "extra_class")(Html("theText"))(vfc, msgsProv).body must contain("theText
") } "allow setting extra arguments and remove those arguments with false values or with underscored names" in { - val body = b3.static("theLabel", 'extra_attr -> "test", 'true_attr -> true, 'fase_attr -> false, '_underscored_attr -> "test")(Html("theText"))(vfc, msgsProv).body + val body = b3.static("theLabel", Symbol("extra_attr") -> "test", Symbol("true_attr") -> true, Symbol("fase_attr") -> false, Symbol("_underscored_attr") -> "test")(Html("theText"))(vfc, msgsProv).body body must contain("extra_attr=\"test\"") body must contain("true_attr=\"true\"") body must not contain ("false_attr=\"false\"") @@ -564,7 +564,7 @@ object HelpersSpec extends Specification { } "allow setting extra arguments and remove those arguments with false values or with underscored names" in { - val body = buttonTypeBody('extra_attr -> "test", 'true_attr -> true, 'fase_attr -> false, '_underscored_attr -> "test") + val body = buttonTypeBody(Symbol("extra_attr") -> "test", Symbol("true_attr") -> true, Symbol("fase_attr") -> false, Symbol("_underscored_attr") -> "test") body must contain("extra_attr=\"test\"") body must contain("true_attr=\"true\"") body must not contain ("false_attr=\"false\"") @@ -572,7 +572,7 @@ object HelpersSpec extends Specification { } "be rendered correctly" in { - val body = buttonTypeBody('id -> "someid", 'class -> "btn btn-default") + val body = buttonTypeBody(Symbol("id") -> "someid", Symbol("class") -> "btn btn-default") body must contain("") } } @@ -598,16 +598,16 @@ object HelpersSpec extends Specification { "@inputWrapped" should { "be equivalent to inputType for an empty wrapper" in { - val bodyInputType = clean(b3.inputType("text", fooField, 'id -> "someid").body) - val body = clean(b3.inputWrapped("text", fooField, 'id -> "someid")(x => x).body) + val bodyInputType = clean(b3.inputType("text", fooField, Symbol("id") -> "someid").body) + val body = clean(b3.inputWrapped("text", fooField, Symbol("id") -> "someid")(x => x).body) body must be equalTo bodyInputType } "wrap the input" in { - val bodyInputType = clean(b3.inputType("text", fooField, 'id -> "someid").body) + val bodyInputType = clean(b3.inputType("text", fooField, Symbol("id") -> "someid").body) val (wrapperPre, wrapperPost) = ("args)disabled and readonly attributesb3.inputType @@(inputType: String, field: Field, args: (Symbol,Any)*)(implicit handler: B3FieldConstructor, @BSVersion.msgsArg)
- It renders a simple input with a specific type attribute and it adds class="form-control" by default, but you can add an extra class with 'class -> "extra_class".
+ It renders a simple input with a specific type attribute and it adds class="form-control" by default, but you can add an extra class with Symbol("class") -> "extra_class".
b3.text @@(field: Field, arg
It is a short version of b3.inputType for type="text".
@bsExampleWithCode {
- @b3.text( fooForm("name"), '_label -> "Name", 'placeholder -> "John Doe" )
+ @b3.text( fooForm("name"), Symbol("_label") -> "Name", Symbol("placeholder") -> "John Doe" )
}{
- @@b3.text( fooForm("name"), '_label -> "Name", 'placeholder -> "John Doe" )
+ @@b3.text( fooForm("name"), Symbol("_label") -> "Name", Symbol("placeholder") -> "John Doe" )
}
@@ -133,9 +133,9 @@ b3.password @@(field: Fi
For security reasons, this helper doesn't display the possible value the field could have (for example when the form is reloaded after a validation failure).
@bsExampleWithCode {
- @b3.password( fooForm("password"), '_label -> "Password", '_help -> "With at least 8 characters" )
+ @b3.password( fooForm("password"), Symbol("_label") -> "Password", Symbol("_help") -> "With at least 8 characters" )
}{
- @@b3.password( fooForm("password"), '_label -> "Password", '_help -> "With at least 8 characters" )
+ @@b3.password( fooForm("password"), Symbol("_label") -> "Password", Symbol("_help") -> "With at least 8 characters" )
}
@@ -144,11 +144,11 @@ b3.file @@(field: Field, arg
It is a short version of b3.inputType for type="file".
@bsExampleWithCode {
- @b3.file( fooForm("file"), '_label -> "File" )
- @b3.file( fooForm("file"), '_label -> "File", 'class -> "form-control" )
+ @b3.file( fooForm("file"), Symbol("_label") -> "File" )
+ @b3.file( fooForm("file"), Symbol("_label") -> "File", Symbol("class") -> "form-control" )
}{
- @@b3.file( fooForm("file"), '_label -> "File" )
- @@b3.file( fooForm("file"), '_label -> "File", 'class -> "form-control" )
+ @@b3.file( fooForm("file"), Symbol("_label") -> "File" )
+ @@b3.file( fooForm("file"), Symbol("_label") -> "File", Symbol("class") -> "form-control" )
}
@@ -158,9 +158,9 @@ b3.textarea @@(field: Fi
It renders a textarea and it adds class="form-control" by default.
@bsExampleWithCode {
- @b3.textarea( fooForm("foo"), '_label -> "Textarea", 'rows -> 3 )
+ @b3.textarea( fooForm("foo"), Symbol("_label") -> "Textarea", Symbol("rows") -> 3 )
}{
- @@b3.textarea( fooForm("foo"), '_label -> "Textarea", 'rows -> 3 )
+ @@b3.textarea( fooForm("foo"), Symbol("_label") -> "Textarea", Symbol("rows") -> 3 )
}
@@ -173,7 +173,7 @@ b3.checkbox @@(field: Fi
The special '_text argument lets you put a text after the checkbox.
- Regarding to the checked attribute, if you want to set it to true as default, use '_default -> true.
+ Regarding to the checked attribute, if you want to set it to true as default, use Symbol("_default") -> true.
And if you need to force its value use directly the 'checked argument.
@@ -181,32 +181,32 @@
b3.checkbox @@(field: Fi
<input type="hidden">.
@bsExampleWithCode {
- @b3.checkbox( fooForm("foo"), '_text -> "Remember me" )
+ @b3.checkbox( fooForm("foo"), Symbol("_text") -> "Remember me" )
}{
- @@b3.checkbox( fooForm("foo"), '_text -> "Remember me" )
+ @@b3.checkbox( fooForm("foo"), Symbol("_text") -> "Remember me" )
// uses "bar" as value for the checkbox
- @@b3.checkbox( fooForm("foo"), '_text -> "Remember me", 'value -> "bar" )
+ @@b3.checkbox( fooForm("foo"), Symbol("_text") -> "Remember me", Symbol("value") -> "bar" )
// checked by default (if the form is filled, this value will be taken)
- @@b3.checkbox( fooForm("foo"), '_text -> "Remember me", '_default -> true )
+ @@b3.checkbox( fooForm("foo"), Symbol("_text") -> "Remember me", Symbol("_default") -> true )
// always checked (even if the form has been filled with a false)
- @@b3.checkbox( fooForm("foo"), '_text -> "Remember me", 'checked -> true )
+ @@b3.checkbox( fooForm("foo"), Symbol("_text") -> "Remember me", Symbol("checked") -> true )
// disabled -> it will NOT be sent within the POST request
- @@b3.checkbox( fooForm("foo"), '_text -> "Remember me", 'disabled -> true )
+ @@b3.checkbox( fooForm("foo"), Symbol("_text") -> "Remember me", Symbol("disabled") -> true )
// readonly -> it will be sent within the POST request
- @@b3.checkbox( fooForm("foo"), '_text -> "Remember me", 'readonly -> true )
+ @@b3.checkbox( fooForm("foo"), Symbol("_text") -> "Remember me", Symbol("readonly") -> true )
}
Note you can use any value for the _text argument.
b3.radio @@(field: Field, o
It has an additional special _inline argument to make it an inline radio (for vertical and horizontal forms).
@bsExampleWithCode {
- @b3.radio( fooForm("foo_radio1"), options = Seq("M"->"Male","F"->"Female"), '_label -> "Radio Group" )
+ @b3.radio( fooForm("foo_radio1"), options = Seq("M"->"Male","F"->"Female"), Symbol("_label") -> "Radio Group" )
}{
@@opts = @@{ Seq("M"->"Male","F"->"Female") }
- @@b3.radio( fooForm("foo"), options = opts, '_label -> "Radio Group" )
+ @@b3.radio( fooForm("foo"), options = opts, Symbol("_label") -> "Radio Group" )
// an inline radio within a vertical or horizontal form
- @@b3.radio( fooForm("foo"), options = opts, '_label -> "Radio Group", '_inline -> true )
+ @@b3.radio( fooForm("foo"), options = opts, Symbol("_label") -> "Radio Group", Symbol("_inline") -> true )
// with value "F" by default (if the form is filled, this value will be taken)
- @@b3.radio( fooForm("foo"), options = opts, '_label -> "Radio Group", 'value -> "F" )
+ @@b3.radio( fooForm("foo"), options = opts, Symbol("_label") -> "Radio Group", Symbol("value") -> "F" )
// disabled -> it will NOT be sent within the POST request
- @@b3.radio( fooForm("foo"), options = opts, '_label -> "Radio Group", 'disabled -> true )
+ @@b3.radio( fooForm("foo"), options = opts, Symbol("_label") -> "Radio Group", Symbol("disabled") -> true )
// readonly -> it will be sent within the POST request
- @@b3.radio( fooForm("foo"), options = opts, '_label -> "Radio Group", 'readonly -> true )
+ @@b3.radio( fooForm("foo"), options = opts, Symbol("_label") -> "Radio Group", Symbol("readonly") -> true )
}
Note you can use any value for the options argument.
b3.radio @@(field: Field, args: (Symbol, Any)*)(content: Tuple6[Boolean, Boolean, String, String, Option[String], Map[Symbol, Any]] => Html)(implicit handler: B3FieldConstructor, @BSVersion.msgsArg)b3.radioOption @@(inputValue: Any, label: Any
If you need more versatility you can fully customize your radio options:
@bsExampleWithCode {
- @b3.radio( fooForm("foo_radio3"), '_label -> "Ok, now that we're alone, what do you really prefer?" ) { implicit extraInfo =>
+ @b3.radio( fooForm("foo_radio3"), Symbol("_label") -> "Ok, now that we're alone, what do you really prefer?" ) { implicit extraInfo =>
@b3.radioOption("B", Html("""Beer """))
- @b3.radioOption("B", Html("""Coffee """), 'disabled -> true)
+ @b3.radioOption("B", Html("""Coffee """), Symbol("disabled") -> true)
}
}{
- @@b3.radio( fooForm("foo3"), '_label -> "Ok, now that we're alone, what do you really prefer?" ) { implicit extraInfo =>
+ @@b3.radio( fooForm("foo3"), Symbol("_label") -> "Ok, now that we're alone, what do you really prefer?" ) { implicit extraInfo =>
@@b3.radioOption("B", Html("Beer "))
- @@b3.radioOption("B", Html("Coffee "), 'disabled -> true)
+ @@b3.radioOption("B", Html("Coffee "), Symbol("disabled") -> true)
}
}
@@ -272,19 +272,19 @@ b3.select @@(field: Field,
one and a <input type="hidden">.
@bsExampleWithCode {
- @b3.select( fooForm("foo"), options = fruits, '_label -> "Select" )
- @b3.select( fooForm("foo"), options = fruits, '_label -> "Disabled", 'disabled -> true )
- @b3.select( fooForm("foo"), options = fruits, '_label -> "Readonly", 'readonly -> true )
+ @b3.select( fooForm("foo"), options = fruits, Symbol("_label") -> "Select" )
+ @b3.select( fooForm("foo"), options = fruits, Symbol("_label") -> "Disabled", Symbol("disabled") -> true )
+ @b3.select( fooForm("foo"), options = fruits, Symbol("_label") -> "Readonly", Symbol("readonly") -> true )
}{
@@fruits = @@{ Seq("A"->"Apples","P"->"Pears","B"->"Bananas") }
- @@b3.select( fooForm("foo"), options = fruits, '_label -> "Select" )
+ @@b3.select( fooForm("foo"), options = fruits, Symbol("_label") -> "Select" )
// disabled -> it will NOT be sent within the POST request
- @@b3.select( fooForm("foo"), options = fruits, '_label -> "Select", 'disabled -> true )
+ @@b3.select( fooForm("foo"), options = fruits, Symbol("_label") -> "Select", Symbol("disabled") -> true )
// readonly -> it will be sent within the POST request
- @@b3.select( fooForm("foo"), options = fruits, '_label -> "Select", 'readonly -> true )
+ @@b3.select( fooForm("foo"), options = fruits, Symbol("_label") -> "Select", Symbol("readonly") -> true )
}
You can add a default first value using the argument '_default with a string.
@@ -294,11 +294,11 @@
b3.select @@(field: Field,
and if any other option is selected this default one will not appear at all.
@bsExampleWithCode {
- @b3.select( fooForm("foo"), options = fruits, '_label -> "With default", '_default -> "Select an option" )
- @b3.select( fooForm("foo"), options = fruits, '_label -> "With default and Pears as value", '_default -> "Select an option", 'value -> "P" )
+ @b3.select( fooForm("foo"), options = fruits, Symbol("_label") -> "With default", Symbol("_default") -> "Select an option" )
+ @b3.select( fooForm("foo"), options = fruits, Symbol("_label") -> "With default and Pears as value", Symbol("_default") -> "Select an option", Symbol("value") -> "P" )
}{
- @@b3.select( fooForm("foo"), options = fruits, '_label -> "Select", '_default -> "Select an option" )
- @@b3.select( fooForm("foo"), options = fruits, '_label -> "With default and Pears as value", '_default -> "Select an option", 'value -> "P" )
+ @@b3.select( fooForm("foo"), options = fruits, Symbol("_label") -> "Select", Symbol("_default") -> "Select an option" )
+ @@b3.select( fooForm("foo"), options = fruits, Symbol("_label") -> "With default and Pears as value", Symbol("_default") -> "Select an option", Symbol("value") -> "P" )
}
@@ -306,15 +306,15 @@
b3.select @@(field: Field,
In that case, the '_default argument will be ignored.
@bsExampleWithCode {
- @b3.select( fooForm("foo"), options = fruits, '_label -> "Select Multiple", 'multiple -> true )
+ @b3.select( fooForm("foo"), options = fruits, Symbol("_label") -> "Select Multiple", Symbol("multiple") -> true )
}{
@@fruits = @@{ Seq("A"->"Apples","P"->"Pears","B"->"Bananas") }
- @@b3.select( fooForm("foo"), options = fruits, '_label -> "Fruits", 'multiple -> true )
+ @@b3.select( fooForm("foo"), options = fruits, Symbol("_label") -> "Fruits", Symbol("multiple") -> true )
// with value "A" and "B" by default
// it is a string with every value separated by commas
- @@b3.select( fooForm("foo"), options = fruits, '_label -> "Fruits", 'multiple -> true, 'value -> "A,B" )
+ @@b3.select( fooForm("foo"), options = fruits, Symbol("_label") -> "Fruits", Symbol("multiple") -> true, Symbol("value") -> "A,B" )
}
b3.select @@(field: Field, args: (Symbol,Any)*)(content: Set[String] => Html)(implicit handler: B3FieldConstructor, @BSVersion.msgsArg)b3.selectOption @@(value: Any, name: Any, arg
If you need more versatility you can fully customize your select options:
@bsExampleWithCode {
- @b3.select( fooForm("foo"), '_label -> "Grouped select" ) { implicit values =>
+ @b3.select( fooForm("foo"), Symbol("_label") -> "Grouped select" ) { implicit values =>
}
- @b3.select( fooForm("foo"), '_label -> "Fruits select (lemon preselected)" ) { implicit values =>
+ @b3.select( fooForm("foo"), Symbol("_label") -> "Fruits select (lemon preselected)" ) { implicit values =>
}
}{
- @@b3.select( fooForm("foo"), '_label -> "Grouped select" ) { implicit values =>
+ @@b3.select( fooForm("foo"), Symbol("_label") -> "Grouped select" ) { implicit values =>
}
@@ -370,10 +370,10 @@ b3.selectOption @@(value: Any, name: Any, arg
Fruit(5L, "Banana", false)
)}
- @@b3.select( fooForm("foo"), '_label -> "Fruits select (lemon preselected)" ) { implicit values =>
+ @@b3.select( fooForm("foo"), Symbol("_label") -> "Fruits select (lemon preselected)" ) { implicit values =>