简体   繁体   中英

Dynamic value of textarea with Play framework with Silhouette

There is a need to perform parsing of data from textarea and keep it safe on page update to let it be easily changeable for further experiments.

Before I have added the Silhouette to the app everything was pretty ok.

The page was getting the input parameter:

@(textToParse: String)

and its value was passed to plain HTML tag like:

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

But when I have added the Silhouette and used the form field construtor, I have met a problem:

@import b3.inline.fieldConstructor

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

displays hardcoded "@textToParse" instead of the parameter value.

Skipping the quotes ('value -> @textToParse) leads to compilation error:

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

I have checked the documentation on offsite http://silhouette.mohiva.com/docs/ and googled, but with no result.

Any working suggestions will be much appreciated!

Your code must look like:

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

With Twirl , the Play template engine, you start an expression with the @ sign. So in your case you start the expression with the Bootstrap 3 form helper. All other which is in the expression must be normal Scala code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM