Omar Wagih
Omar Wagih

Reputation: 8742

Opposite boolean value of accessed model class' variable in Play Framework

If i'm in template mode and I want to access the oposite of a model class' variable, how would I go about that?

For example I tried:*

@(myForm: Form[MyFormClass])
<input type="text" disabled="[email protected]>

where isSelected is a boolean variable

However, I receive the error:

`identifier' expected but `!' found

I looked around but couldn't find anything..

Upvotes: 1

Views: 204

Answers (1)

Codemwnci
Codemwnci

Reputation: 54914

The @ symbol is just a special character that tells the compiler that Scala code is starting. So, in your code what you are saying is output the ! first, and then process some scala.

What you should be able to do is

@{!myForm.get.isSelected}

As this is is telling scala compiler to execute !myForm.get.isSelected as a statement (because of the braces), and not just to output the value directly.

Upvotes: 5

Related Questions