2
How do I change the label color of my button depending on the value it has?
On my form, in the field status
, I need that when the value is in "open", green, when "finished" is in blue, and when "canceled" in red.
I made a function using Thymeleaf but it is not correct yet.
I got the result doing so:
<span class="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 the red color, referring to the class badge-danger
, because I don’t know how to evaluate the other two options within the function.
I think this site will raise the question.... https://www.w3schools.com/bootstrap4/bootstrap_colors.asp
– Luís Lourenço
This served as a glove for me hermit! Thank you very much, I started messing with Thymeleaf and bootstrap a little while ago, so I got lost with the condition. But that’s exactly what I needed!!
– Rodrigo Nantes