我有一个这样的记录课:
class Address extends Record[Address] {
def meta = Address
object countryCode extends OptionalStringField(this, None) {
override def name = "Country"
var c = "" // this isn't doing anything but I set it up just to build the simple SHtml.select
override def toForm = Full(SHtml.select(List(("usa", "usa"),("ca", "ca")), Empty, c = _ ))
}
...
}
object Address extends Address with MetaRecord[Address] { }
然后此表单显示如下:
object FormPage extends CssBoundLiftScreen {
def formName = "MyForm"
val record = Address.createRecord
field(record.countryCode, FieldBinding("addressCountryCode")
}
在这样的模板中:
<div class="form">
<div class="lift:FormPage">
<div class="fields">
<fieldset>
<div id="MyForm_addressCountryCode_field"></div>
</fieldset>
</div>
</div>
</div>
这是使用Record / CssBoundLiftScreen进行简单文本字段以外的输入的正确方法吗?看起来这个选择不会更新或正确创建记录。我如何让select显示记录字段的值?
答案 0 :(得分:1)
如果查看OptionalStringField的scaladaoc,有两种方法可以通过超类SettableValueHolder
提供,并提供对基础值的访问:get
和{{1} }
def set(in:Option [MyType]):选项[MyType]
将字段的值设置为给定值。注意:因为设置字段可能失败(返回非Full),如果无法设置字段,此方法将返回defaultValueBox。
获取:选项[MyType]
获取值
我怀疑这样的事情适合你:
set