带有 Silhouette Play 框架的 textarea 的动态值

Dynamic value of textarea with Play framework with Silhouette

需要对来自文本区域的数据进行解析,并在页面更新时保证其安全,以便在进一步的实验中可以轻松更改。

在我将 Silhouette 添加到应用程序之前,一切都很好。

页面正在获取输入参数:

@(textToParse: String)

并且它的值被传递给普通的 HTML 标签,例如:

<textarea ...>@textToParse</textarea>

但是当我添加Silhouette并使用表单字段构造器时,我遇到了一个问题:

@import b3.inline.fieldConstructor

@b3.textarea(someForm("text"), 'rows -> "12", 'value -> "@textToParse")

显示硬编码的“@textToParse”而不是参数值。

跳过引号 ('value -> @textToParse) 会导致编译错误:

Type mismatch: found (Nothing) => (Symbol, Nothing), required (Symbol, Any)

我检查了离线文档 http://silhouette.mohiva.com/docs/ 并用谷歌搜索,但没有结果。

任何工作建议将不胜感激!

您的代码必须如下所示:

@b3.textarea(someForm("text"), 'rows -> "12", 'value -> textToParse)

使用 Twirl, the Play template engine, you start an expression with the @ sign. So in your case you start the expression with the Bootstrap 3 表单助手。表达式中的所有其他内容必须是正常的 Scala 代码。