How do I change the label color of my button depending on the value it has?
In my form, in the field status
, I need the value to be "open", green, "completed" in blue, and "canceled" in red.
I did a function using Thymeleaf but it still is not correct.
Igottheresultdoingso:
<spanclass="badge badge-success"
th:text="${f.status.descricao}"
th:classappend="${#strings.toString(f.status) == 'ABERTO' ? 'label-success' : 'badge-danger'}">
</span>
This way it is green when it is in open status, but the other values (canceled, completed) are applied by red color, referring to class badge-danger
, this because I do not know how to evaluate the other two options within the function.