The reason is that SHtml.radio
and SHtml.radioElem
return a ChoiceHolder
instead of a the NodeSeq
that most other items in SHtml
do - as you can see in the API Doc. Because of that, you need to call .toForm
or render the output yourself.
Returning the ChoiceHolder
allows you to customize how each item is displayed, so you can add custom text for the label, etc... If the basic toForm
output didn't work for you, you could do something like:
val choices = SHtml.radio(radioChoices, choice, (resp) => choice = Full(resp))
"@choice" #> choices.items.zipWithIndex.map { case(itm, pos) =>
val rId = "myId-%s".format(pos)
<div class="radio">{
//We'll add a custom ID attribute to the radio button
itm.xhtml.asInstanceOf[Elem] % ("id", rId)
}<label for={ rId }>{
//Output the toString or use some other method to output a label
itm.toString
}</label>
</div>
}
You can find more information on customizing the radio buttons in the Lift Cookbook.
As for why your CSSSelector
is not outputing anything, I am not sure. The code snippet you were trying worked for me. The screenshot below illustrates the output I see with the toForm
method.