When working with play-framework 2.3.x, I am in the process of creating a form and would like to show/hide it based on a model attribute. Typically, setting the style attribute manually using style = "display: none"
and style = "display: block"
works fine. However, when attempting to change the style dynamically based on an attribute passed from the controller, the style does not seem to take effect.
Below is an example code snippet from index.scala.html. The getResultStyle method is utilized to determine the display style, which is then used as the value for the style attribute within the form tag.
@getResultStyle() = @{
if(sf.year_1(1) == 0) {"display: none"} else {"display: block"}
} @main(message) {
<form id="Forecast Result" name="Forecast Result"
style=@getResultStyle()
action="" method="post">
.
.
</form>
Is there a solution to get this functionality to work as intended?